From TextMate to Vim

TextMate is an excellent editor, but it is beginning to show its age. It has a few squeaky wheels that have yet to be oiled, and it looks as though the author may be getting bogged down in the minutiae of his next release. With the next version apparently due sometime after the colonization of Mars, it seemed an auspicious time to try out another editor.

What I like about TextMate

Let me repeat that I like TextMate. I have happily used it for years. It has some wonderful features. It is reasonably fast and its indentation is great. It has a great selection of plugins for a wide variety of languages and is easy to extend with new language modules. It has a decent macro system based on regular expressions that, while not nearly as powerful as scripted editors, provides 80% of what most users need.

Problems with TextMate

TextMate, for all its sterling qualities – and there are many – has a few problems that, while not deal-breakers in themselves, together provide a less-than-satisfactory experience.

Split-windows

This is a rather stark issue, and is a feature that has been promised in the next release. Nevertheless, its absence often means either filling my screen with open TextMate windows or firing up emacs when I need to look at many files at once – or many parts of the same file at once. C, in particular, tends toward long functions, and is especially painful to write in TextMate.

Large files

TextMate handles many open files well, but a single large file will hang the entire application. I can accept a large file taking a long time to load, but please! Load the file in the background, so that I can keep working. Even opening a large file in a second window blocks the entire application. Find and replace also choke on larger documents, sometimes taking minutes to complete.

Key-bindings

TextMate’s key-bindings can be puzzling. Many common commands (especially in Python), such as converting between spaces and tabs in a document, don’t have bindings and are several levels deep in the menu. Other commands of dubious utility are given simple bindings, such as “Execute line/selection inserting result” (control-R.) Many have extremely difficult combinations, such as control-alt-command-D to toggle to project drawer, or control-option-shift-P to toggle text mode (and then – because several bundles use this same key-binding, god knows why – you are given a drop-down to choose which command you wanted.)

Choosing a new editor

I was initiated into the cult of emacs in college and have used it for several years. I’ve played with BBEdit (which I think is horribly cluttered and completely lost in the pre-OSX world), NetBeans, and Eclipse (which is, amazingly, slower and clunkier than NetBeans.) I love emacs’ extensibility and its indentation is second to none. It suffers from the key-binding issue as well, though. Becoming efficient in emacs is a journey, not a destination. I find myself spending more time navigating its arcane and bureaucratic configuration system than actually writing code in it.

NetBeans in some ways seems very polished, and the new Python module is very good (I have written about this before.) Refactoring across files is extremely useful. It has good debugger integration. Unfortunately, tight integration with any particular language costs a great deal in load times and can lead to an unresponsive UI. And for god’s sake – why does it have to be such a chore to open a file outside of a project?

Panic’s Coda is pretty and has some neat features, but in the end, SubEthaEdit (its editor) has poor syntax support and its extension system feels very clunky. Editra is nice, but slow and buggy on OSX.

Vim

After a disappointing look around the net for better choices, I decided to give Vim another try. I had a passing familiarity with some of its basic functionality from my days as a system administrator, it is scriptable, and it has a large number of plugins for syntax support.

Lack of distractions

Overall, I am satisfied with Vim’s minimalism. Its indentation is pretty second rate, but I can live with it. Vim feels extremely comfortable. Over the years, Vim has gently washed away all of the “features” of an editor that actually get in the programmer’s way and come up with a system that drastically increases productivity and makes coding a more satisfying experience.

Load speed

While not the primary measure of an editor, load time is important. How many programmers (myself included) give up on Eclipse or NetBeans right away because it takes more than half a minute to start up? Load time is one of those things that, while really just an annoyance, can completely color the experience of using a program. Vim loads quickly. It is one less thing to get in the way of productivity.

Efficiency

Nothing beats Vim for efficiency. If you ever wonder why so many applications have modes that mimic Vim, it is because once you learn Vim’s bindings, there is nothing faster. Jumping around a file with precision is a breeze. Coming from emacs, I expected it to take a lot longer to become comfortable with Vim’s style and bindings, but it has a much milder learning curve than emacs. Search and replace is also fast and easy to use. I quickly found myself giving up in favor of the command line. Copy and paste – the biggest barrier to command-line editors for me – is fast and easy with Vim’s visual mode.

Other features

Vim 7 has auto-complete, although I rarely use it. I’m much more comfortable with an enormous stack of O’Reilly books. Vim’s code folding is also very nice. I generally turn code folding off because it slows most editors down so drastically, but it does not appear to affect Vim.

Two of Vim’s features really stand out for me: reformatting text and retabbing a document. I love being able to convert a file’s tabs to spaces just by typing :retab. It is much more efficient than having to go through two levels of menus in TextMate. And being able to reformat Python doc strings is very useful. It removes an annoyance that can make updating documentation a real chore.

Conclusion

Vim strikes the perfect balance for me. At first glance, it seems archaic, especially for those born after the mouse became standard. After a few days of using it, though, I find myself enabling Vim bindings mode in any application that has it, using the Vimperator plugin for Firefox, and wishing that OSX’s terminal was more easily scriptable. If you haven’t used Vim, give it a chance. Coming from a graphic editor like TextMate, it is a much different experience and, arguably, a more satisfying one.

Here are some other folks’ experiences with the transition in both directions:

Loading ... Loading ...

Edit [2009-08-03 15:50]: added links to similar stories

Leave a comment | Trackback
Aug 3rd, 2009 | Posted in Programming, Tips
Tags: , ,
  1. dude
    Aug 3rd, 2009 at 11:37 | #1

    I’m a vim user myself but I use TexMate at work on our Rails project and I just wanted to point out that all the TextMate shortcuts you dislike can be trivially remapped to anything you like. I made my own bundle with remappings for all of my commonly used stuff in about 20 minutes. Cheers!

    • Jeff
      Aug 3rd, 2009 at 11:52 | #2

      That’s true. Of course, you still have to contend with clashing bindings bringing up a drop-down.

      • fc
        Aug 3rd, 2009 at 15:13 | #3

        But if the conflict drop-down is that big of an issue, you can remap all of those so they don’t conflict anymore. If you find that “going through two levels of menus” is a problem, give that command a key-binding.

        The other complaints really ring true, but the key bindings are not as issue. TextMate may not handle them how you want on first running, but it has an excellent system for customizing them.

    • will
      Aug 3rd, 2009 at 15:39 | #4

      I just use rails.vim by tpope

  2. Jijesh
    Aug 3rd, 2009 at 12:23 | #5

    I’ a vim user and I love it more than any editor. I’m using vim for rails development also . inspired from this http://www.akitaonrails.com/2009/1/4/rails-on-vim-in-english

  3. Aug 3rd, 2009 at 12:35 | #6

    Vim indentation is programmable as well as Vim syntax highlighting. This feature just appears later than highlighting, and therefore the library of good indentation modes is not as rich as library of good highlighting modes. But if you want me to write an indentation mode for newLISP… I do not give a promise, but I’ll consider this. ;-)

  4. Aug 3rd, 2009 at 14:16 | #7

    I really like Sublime Text, but’s its Windows only. I actually wrote a blog entry about it today if you care to look at it.

    On UNIX, its vim for me!

  5. Stu
    Aug 3rd, 2009 at 14:25 | #8

    jEdit, its everything textmate wishes it was, fully bindable, split windows h/v.. metric tonnes of plugins. jEdit rocks, as long as you run the current dev version (as the stable is old, but they wont mark the dev releases as stable)

    • Stephen
      Aug 4th, 2009 at 13:49 | #9

      Until Textmate 2 comes out, I will assuredly be staying on jEdit for all of my development. Fast, with configurable folding, a well-designed project management plugin, excellent large file support, and oodles more features. If you’re willing to put up with ugly looks on OS X, then this is absolutely the best editor I’ve ever come across.

  6. jft
    Aug 3rd, 2009 at 14:35 | #10

    I think you might like plan9 tools such as the “sam” editor or “acme” editor.

    good luck — its your most important tool as a programmer

  7. Lorenzo
    Aug 3rd, 2009 at 15:55 | #11

    Yup, on windows i use Sublime Text too:

    - split windows
    - auto-complete
    - plugin system
    - project support
    - powerful search and replace (also regex based)
    - syntax coloring
    - dark background (more readable IMHO)
    - minimap (if you care about it)

    L.

  8. Olex
    Aug 3rd, 2009 at 15:55 | #12

    Kate has a vim mode, great highlighting / etc support, and a front-end to changing keybindings, and adding your own to plugins. Usually working with it is similar to vim, but then you hit some unbound (or more likely, very obscure and useless) vim button, and there you go, you’re browsing which file to switch to, or just activated some plugin to go-to-source of the method name your cursor is on. Good stuff.

    For very basic html / css hackjobs, there’s an alpha of inType, which does multi-line selection and style very very well. Windows, however.

  9. rationalthug
    Aug 3rd, 2009 at 16:06 | #13

    What about Espresso?

  10. David Turnbull
    Aug 3rd, 2009 at 16:46 | #14

    While I love vim’s movement commands, I also curse them for making it completely impossible for me to switch to any other editor, say, one with a decent scripting language.

    Anyway, if you’re a vim learner, the best way to increase your power is searching github for ‘dotfiles’ or ‘vimrc’ (or use google to do it). There are some quite amazing plugins e.g. Jamis’ TextMate FuzzyFinder extension, rails.vim, TabLine, Snippets..

    Echoing your sentiments, indentation is a pain, and autocompletion is worse than it should be (Omni not a superset of standard in-buffer completion? wtf)

  11. Nif
    Aug 3rd, 2009 at 17:10 | #16

    I don’t know if this is what you’re running into, but one common problem with vim’s python indentation is that you have both “filetype indent on” and “set smartindent” set. If there’s indentation found for a filetype it’s always better than just smartindent, but it doesn’t turn smartindent off automatically. And smartindent does some annoying things like always moving ‘#’s into column 0, under the assumption they’re preprocessor directives, not comments.

    If you have filetype plugins enabled (my .vimrc says “filetype plugin indent on”, which I think was the default), you can add a “setlocal nosi” to a .vim/ftplugin/python.vim (or if you want to split it up to allow multiple python ftplugins, I use .vim/ftplugin/python/settings.vim) to make sure smartindent is off when editing python files. My ftplugin/python/settings.vim has:

    setlocal softtabstop=4
    setlocal shiftwidth=4
    setlocal expandtab
    setlocal smarttab
    setlocal nosmartindent

    " Options for python syntax highlighting
    let python_highlight_all = 1
    let python_slow_sync = 1

    There’s also a newer, better python.vim syntax file on vim.org. Make sure you download the 2.x version, not 3.x, and drop it into ~/.vim/syntax/python.vim.

    • Jeff
      Aug 4th, 2009 at 09:05 | #17

      Thanks! That is useful to know about.

  12. Nif
    Aug 3rd, 2009 at 17:13 | #18

    Opps, those options for the python syntax highlighting seem to have dropped outside the code block. They’re part of my .vim/ftplugin/python/settings.vim file too, and just do stuff like turn on highlighting of mismatched spaces and tries to keep it from losing its highlighting when editing a large file.

  13. Aug 3rd, 2009 at 17:36 | #19

    One of the best editors i know is Scribes.
    It has a very radical approach, with a limited featureset.
    But everything is very well implemented

  14. Nat
    Aug 3rd, 2009 at 17:56 | #20

    I use vim for just about everything, especially after leaning about :set paste.

    But when I need a mouse, I find Gnome’s gedit to be rather amazing.

    /Nat

    • Anthony
      Aug 3rd, 2009 at 19:24 | #21

      If you’re setting the paste mode just for a single paste from the system clipboard, try using “+p instead. “+ refers to the normal clipboard buffer.

  15. Jonatan
    Aug 3rd, 2009 at 18:15 | #22

    I wish TextMate would exist on GNU/Linux. Until a decent and modern text editor exists for Linux I am very happy for Emacs.

    I’ve just recently seriously begun my Emacs journey,

  16. Biggie Smalls
    Aug 3rd, 2009 at 18:41 | #23

    :set mouse=a

    Now try scrolling, clicking on text and clicking on tabs.

  17. Aug 3rd, 2009 at 18:42 | #24

    Since you[r poll] asked: My “Other” vote is: Diakonos. An extremely user-friendly, yet featureful console editor.

  18. Dude
    Aug 3rd, 2009 at 19:30 | #25

    With Vim, you can go on almost any machine and fire it up as well. TextMate can’t do that.

    Vim is a programmers/system-administrators army knife, while TextMate is a really nice can-opener.

  19. Aug 3rd, 2009 at 20:20 | #26

    Good write up.

    I as well love vim and use it exclusively on linux.

    However, one thing i find funny, on windows i use e – text editor, a clone of textmate. E solves both of your major gripes with textmate split windows and configurable key bindings.

  20. Aug 3rd, 2009 at 21:13 | #27

    “C, in particular, tends toward long functions…”

    eh? Unless you often have switch statements with loads of cases for some weird reason, that seems a strange thing to say.

  21. Aug 3rd, 2009 at 21:17 | #28

    Back when I was using Homesite to build websites (funny, huh), my coworker, who was a guru, used Vim. Naturally, because I was a poser and wanted to be like him, I struggled my way up the Vi learning curve. Best thing I ever did for my code.

    Since we’re talking customization, let’s bring themes into the mix:

    http://blog.infinitered.com/entries/show/8

  22. CodeCutter
    Aug 3rd, 2009 at 22:14 | #29

    For programming on the Windows platform I just power up .

  23. CodeCutter
    Aug 3rd, 2009 at 22:15 | #31
  24. Aug 3rd, 2009 at 23:04 | #32

    I prefer Scite. It isn’t as minimalist as Vim, but it is very lightweight and is extensible via Lua.

    I started using it when learning assembly language in college. Things clicked. ;)

  25. junior
    Aug 3rd, 2009 at 23:44 | #33

    I love Vim, but I recently made the switch to Emacs for org-mode, which I can now not live without. Seriously, it is one of the best scripts I have ever encountered. But I also have to say the Emacs handles indentation better than any editor I have ever used. Emacs is a never ending train ride of configuration. Emacs-lisp is an archaic cluster fuck of parenthesis, and after nearly four months of using Emacs, I still do not understand. Yeah I could learn emacs lisp, but that would take time. I knew vimscript almost immediately because it almost looks like shell script. Just my two cents.

    • Jeff
      Aug 4th, 2009 at 06:34 | #34

      I agree that emacs has the best indentation of any editor available. In fact, I think I mentioned that in the article. And that *is* a big thing. But it is not the only thing, and when it came down to it, the most important thing for me was the ability to get things done easily, and vim provided that more than any other editor – for me, in any case.

  26. grs
    Aug 3rd, 2009 at 23:56 | #35

    Major nit – Vim is an *enhancement* of vi.

    ‘Over the years, Vim has gently washed away all of the “features” of an editor that actually get in the programmer’s way’ is wrong, they weren’t there in the first place!

    Those of us who grew up in the Late Cretaceous and whose first experience of a “full screen editor” was vi on BSD UNIX made do with a much smaller command set than is supplied by vim/gvim, not to mention no colours or automatic re-formatting or all those other niceties that Vim has added.

    • Jeff
      Aug 4th, 2009 at 06:35 | #36

      Thank you for stopping short of bringing up punch cards ;)

  27. Aug 4th, 2009 at 02:17 | #37

    Two of Vim’s features really stand out for me: reformatting text and retabbing a document. I love being able to convert a file’s tabs to spaces just by typing :retab. It is much more efficient than having to go through two levels of menus in TextMate.

    You’re gonna have to update your (otherwise nice) article on that one. TextMate has a “Select bundle item” command (not sure on the keybinding, on windows right now. But e-editor has ctrl-alt-t). It’s very useful, since its hard to remember all the bundle key bindings, or even what commands are available. So for certain things I’ve learned the name of the command rather than the binding (I type “entities” to select the convert to html entities command)

    I totally agree on file load speed and search and replace though. I haven’t felt the need for split screen, but I can see how it can be useful. I do hope TextMate 2 fixes these issues (and that it’s released soon).

  28. Craig
    Aug 4th, 2009 at 03:34 | #38

    Hi, long time Vim user, first time commenter :)

    Not got a lot to add to all this, really. One thing I love about Vim is that I can copy my .vimrc to various servers I have shell accounts on and use the exact same configuration via ssh as I do in MacVim.

    Just one point though … what is it about Terminal that is NOT easily scriptable? It’s a standard bash shell, same as just about any Linux distro.

    • Jeff
      Aug 4th, 2009 at 06:38 | #39

      Just one point though … what is it about Terminal that is NOT easily scriptable? It’s a standard bash shell, same as just about any Linux distro.

      As a simple example, you cannot easily do something like `xterm -e vim $SOMEFILE` in a shell script. I try not to touch Apple Script with my hands.

  29. Aug 4th, 2009 at 08:45 | #40

    gedit on linux for me. Straight-up vi for quick editing. gedit had a whole bunch of things I never knew it had until I enabled the plugins and snippets…

  30. mitja
    Aug 4th, 2009 at 08:59 | #41

    Great. Just the post I needed to inspire confidence. I’ve been dissatisfied with the aforementioned loading times of all major IDEs and after giving emacs I try I just couldn’t bear the idea of using modifier keys for the simplest tasks like moving around a document. Navigation in general seems fairly complex.

    Vim on the other hand is snappy, quick to load, and easy to navigate. Thanks for the reassurance!

  31. poelzi
    Aug 4th, 2009 at 10:27 | #42

    I’m using PIDA with medit as editor component. But most use PIDA with VIM and some Emacs. I’m running trunk, btw. Last real release i way to old :-) but soon…

    ps: your page is broken. back button on comment error page makes the text disapear. one of the most annoying bugs !!!

    • Jeff
      Aug 4th, 2009 at 12:15 | #43

      I’ve never actually been able to get PIDA working on OSX, since the macports GTK packages are broken. I’m working on getting a linux book for work, though, and perhaps I’ll try PIDA on that.

  32. Sébastien
    Aug 5th, 2009 at 11:08 | #44

    I use Emacs with Vim key bindings (Viper + wimpulse.el). I love it.

  33. Aug 6th, 2009 at 04:28 | #45

    VIM FTW!
    VIM FTW!
    VIM FTW!
    VIM FTW!
    VIM FTW!

    Simple, vim is THE best editor :)

  34. TT
    Aug 6th, 2009 at 05:13 | #46

    Sorry, VIM is handy only when emacs is not around (not in default installation in most *nix dist. For me, emacs rocks. If i need something more managable, TextMate is my best friend.

  35. Shaun
    Aug 6th, 2009 at 07:52 | #47

    Since your a Mac user, give MacVim a try. It’s VIM beautifully integrated into Mac.

    Good article. Except for the last statement about OS X’s terminal not being scriptable. What exactly do you mean by that? The terminal shell is bash, easily (one of) the most scriptable shell interface(s) on the planet. Always remember that your pretty Mac UI is a fully certified UNIX OS underneath, and that your terminal is your interface into that underlying OS. Whatever you wan to script in that shell, I assure you that you can do it.

  36. littleredspiders
    Aug 7th, 2009 at 09:07 | #48

    I love Vim. It’s an excellent editor for someone with small fingers (Emacs kicks all sorts of booty, but the modifier keys are RSI-inducing if you try to use them at speed with short fingers).

    The apparent stagnation of Textmate led me to trying out MacVim, which I liked lots and from there I started testing all sorts of FLOSS applications with a view to replacing what I was using daily. I found out that Inkscape and Gimp did what I needed them to and so I could kiss goodbye to hefty Adobe licences (I design for screen only so no need for CMYK in Gimp). After that I just took the plunge – ditched OS X to go fully FLOSS.

    And I’m loving it.

  37. paul
    Sep 3rd, 2009 at 14:20 | #49

    I really tried to like textmate but realized I would be paying 50 dollars for the command-T functionality because that’s the only thing I found useful.
    No thanks.
    I’ll stick with macvim.

  38. Nov 13th, 2009 at 22:06 | #50

    I can’t believe nobody has mentioned Komodo Edit (the free one — Komodo IDE costs money). It has vi keybindings. The support is not extensive to the point of being able to say ‘this is vim embedded in komodo’, but it’s pretty good, and world’s better than the attempts I’ve seen at a vim plugin for textmate. The vim keybindings support a good amount of the movement functionality, which is really the bulk of what I want (need, really: if I don’t have it I end up with j’s and k’s in my code).

    It supports h,j,k,l, find using ‘/’ and ‘n’ for ‘next’, moving by word, $ and 0 for begin/end of line, G to jump to a line number (or just ‘G’ to jump to end of file), x, dd, Y, p/P, zc/zo for code-folding… there’s more I’m not remembering to be sure. It even supports :w, which will open a ‘save as…’ dialog for new files. Unfortunately, if you want to save the current file under a different name, you still have to use the menus for that for whatever reason, but you get a lot of features, and the editor doesn’t slow down a bit. I’ve been using it for at least a couple years now.

    I use vim if I have to edit remote code, and I’ve recently started playing with MacVim to see if it adds any benefit (I can’t find one at first glance). I’m always on the lookout for a “killer editor”, though :)

  39. jd
    Mar 19th, 2010 at 16:51 | #51

    vim definitely, i’ve tried textmate and coda for a hot minute, but why bother…vim is more advanced and if you know all the commands, faster than the latter will ever be plus i can use it if I am in ssh, on an ever popular ubuntu/redhat orr windows. if i want something more its straight into eclipse.

  40. Thorarinn Sigurdsson
    Apr 23rd, 2010 at 19:54 | #52

    I also love Vim. The modal editing model is, simply put, the greatest thing since sliced bread. But, by design, it’s not very flexible. I read that vi was designed to interface with other unix applications that would handle non-editing tasks, while vi itself was only supposed to be a pure editor. Integrating your editor into your workflow – debugging etc. – is absolutely essential.

    I was hungering for that kind of integration, and therefore I’m currently using Emacs with Vimpulse (an enhanced version of viper-mode), and loving it. Of course it doesn’t quite feel like 100% vim when editing (I’d say I’m at about 95% of my pure-vim editing efficiency), but the integration of external features (debugging, etc) is very attractive to me. On the whole, I feel like I’m getting the best of both worlds. I still have Vim’s editing efficiency, while getting access to emacs’ crazy extensibility and all those IDE-attributes that Vim was never intended to take on. I could say that my editor is still Vim, but the IDE is Emacs.

    Has anyone been through a similar experience?

  41. Rick
    Reply | Quote
    Nov 28th, 2010 at 01:29 | #53

    Some things are just not as polished in vim though (relative to textmate) that still have me frustrated. For example, despite how great file navigation is, it’s often nice to have a project tree (especially when first learning rails), so I installed NERDTree. Ok, fine, but now when you’re in nerd tree and you start doing things you have to remember to leave the nerdtree window and move back to your main window or else you can end up opening things in the nerd tree buffer.

    For example, I use command-t plugin (way better than fuzzy finder btw), but if you are in the nerdTree buffer and try to open a file with command-t, it’ll open the file in the nerdTree buffer. You can get around with this by hitting ctrl-k first but that’s sort of a pain.

    Right now I’m also having issues with code folding in vim, I’m using indent as the ‘foldmethod’ type, and the behavior is just really odd. I’m sure I’ll get it worked out as to what’s wrong, but the time I have to constantly spend ‘mucking around’ in vim – with my .vimrc file, plugins, etc gets very time consuming. (I know it should pay off in the end, but it seems to be a never ending thing I’m having to do.)