Why I switched from vim to emacs
UNIX text editor mastery has long been the hallmark of top coders in our profession, and I don't anticipate that changing any time soon. Last time we did a poll at Facebook, about 50% of our engineers reported using vim, about 30% using emacs, and the remaining 20% a variety of other editors and IDEs. So the editor holy war which started in the mid 1980s doesn't show any signs of stopping soon.
Approximately a year and a half ago (Februrary 2010), I took the plunge. I switched from vim to emacs as my primary text editor for coding tasks. Since I'd been using vim for the previous 3 years, it goes without saying that this was a long and at times arduous journey. Today, though, I use both text editors almost every day, preferring emacs for coding and vim for simpler editing tasks. I think that this gives me a unique perspective on the holy war between these two camps, so I'm going to use this blog post to share the particular reasons why I switched.
The Keyboard
For the holy inquisitors of vim (who are no doubt already preparing a daring commando raid to bring me to justice as the heretic I am), this argument begins and ends with manipulating text via the keyboard. I personally find the vim model to be marginally better for text manipulation tasks, but for text creation, there are some problems. The thing is that you need to leave insert mode in vim for basically every editing or navigational operation. So if I decide I need a comma at the end of the previous line of code after all, I need to hit Esc k Shift-a. In emacs, it's just C-p C-e.
Note also that chords can be types simultaneously. My pinky hits Caps Lock (a.k.a Ctrl) at the same time as I type p, and the holds it while I type e. In vim, I hit escape, then type k, and THEN type Shift-a. Once I've typed that comma it's Esc j Shift-a to go back to where I was (of course, I could use the arrow keys, but then my cool vim friends would spit on me). Very small edits like this are the norm during the process of creation. Several times during the writing of this essay, I've deleted the previous two words and typed something else, or gone back three words to use a different one. Obviously all of this stuff is customizable (I have my own shortcut system for both vim and emacs), but I think it shows that modal editing isn't necessarily the last word in text creation.
A secondary point is that the emacs keybindings are ubiquitous. Because they don't require any complex logic to figure out what editing mode you're currently in, almost every serous text editing application has them to some extent. For Eclipse, for example, the excellent Emacs+ plugin adds considerable power to Eclipse and makes it a lot more bearable to use. Last time I checked, there was a vim plugin for Eclipse, but it was pretty feature-poor and cost money.
Integration
People who don't use emacs like to joke "emacs is a great operating system... shame it doesn't have a decent text editor". To the advanced user, however, deep integration is the greatest strength of emacs. Programs written as emacs extensions all automatically share your emacs keyboard shortcuts and custom functions, and they all use text buffers as their primary user interface, making them automatically keyboard-friendly.
A great example of this is the ability to run a shell under emacs. The shell just appears in a regular emacs buffer. One of the best things about this is that you can actually interact with shell command output. Say, for example, that you type "git status" and you see that some file you just created isn't being tracked. If you're a vim user, what do you do? You type "git add" and then you either manually enter the path to the file or you get out the mouse and select the path from the git status output. In the emacs shell, you just navigate up to the git output and copy it, then go back down to the prompt and paste it there! You can edit things in the shell *exactly* like how you can edit regular text in emacs, and this works in all interactive programs. If you run IRB or the Python Shell under emacs, your emacs keybindings work and you can paste code in from your text buffers or copy results into files. No more wishing someone would build readline support into their program! It's brilliant.
Lisp
When you get right down to it, emacs is a lisp interpreter that happens to have text editing features. As a matter of fact, emacs lisp is a pretty crummy programming language. It still doesn't have lexical scoping (allegedly coming in Emacs 24), for one thing. And it's still pretty lacking in modern features for string manipulation, like decent regexes. But none of that matters, because it's a hell of a lot more of a real programming language than VimScript. Of course, editors like TextMate and to a lesser extent vim are "scriptable in any language" because their APIs define a small number of constrained places where you might want to change their behavior in some way. The emacs "API", if you can even call it that, lets you change anything, and this includes letting you do absolutely absurd things like try to write a video editor. This means that there are emacs plugins for everything. If you're willing to get your hands dirty, you can almost certainly replicate any feature from any other editor.
Emacs is a text editor for obsessive relentless customizers. The average TextMate user might have downloaded a bundle or two at some point in their life. The average vim user probably has three plugins and a vimrc file around 50 lines long. But emacs doesn't even get good until you hit 20 plugins and several thousand lines of lisp. It's the perfect choice for a control freak power user like me who wants to be consulted on how every tiny editing command should behave.
If you liked this, you should click here to subscribe for regular updates










