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:
Edit [2009-08-03 15:50]: added links to similar stories
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!
That’s true. Of course, you still have to contend with clashing bindings bringing up a drop-down.
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.
I just use rails.vim by tpope
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
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. ;-)
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!
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)
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.
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
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.
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.
What about Espresso?
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)
Curious, do you find the Perl, Python and Ruby scripting support in Vim lacking in some way?
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.
Thanks! That is useful to know about.
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.
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
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
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.
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,
:set mouse=a
Now try scrolling, clicking on text and clicking on tabs.
Since you[r poll] asked: My “Other” vote is: Diakonos. An extremely user-friendly, yet featureful console editor.
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.
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.
“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.
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
For programming on the Windows platform I just power up .
Zeus – http://www.zeusedit.com/whatsnew.html
Zeus – http://www.zeusedit.com/whatsnew.html
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. ;)
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.
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.
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.
Thank you for stopping short of bringing up punch cards ;)
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).
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.
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.
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…
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!
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 !!!
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.
I use Emacs with Vim key bindings (Viper + wimpulse.el). I love it.
VIM FTW!
VIM FTW!
VIM FTW!
VIM FTW!
VIM FTW!
Simple, vim is THE best editor :)
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.
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.
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.
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.
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 :)
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.
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?
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.)