Emacs or Vim as a programming editor (part 3)

Grab the feed

School is a twelve-year jail sentence where bad habits are the only curriculum truly learned.

John Taylor Gatto

Recent comments

This is the final installment in a three parts series about Emacs and Vim as programming editors. I've discussed Emacs in the first part and Vim in the second one. Let's see now which one I choose as my favorite tool for editing source code, and frankly everything else.

So, which one is it?

I think that mnemonic devices don't work for text editors. They may help the conscious part of your brain to feel a little more secure with the new tool but when you work with Emacs or Vim you won't do much thinking. Your fingers are the ones in charge and they have a mind and memory of their own. Piano or guitar players should know what I mean. Hence, no matter how cryptic a key combination may look that's not a real issue.

I wouldn't say Emacs or Vim is better or worse for using a particular key combination; the real issue is how difficult is for your fingers to perform those combinations. With Vim I feel at home and my fingers are happy because most of its commands are just one key or a sequence of keys, no need for chords and fingers twisting. Emacs, on the other side, made me wish to be the elastic guy from the Fantastic Four at times. Was Emacs created by a guy with three hands.

I've been a Vim user for many years and have to admit that, at some point, I fell into the everybody else's editor suck trap. So I decided to start using Emacs in my daily work and see how well it went. I spent a little more than a month using Emacs for everything, even email's drafts, and yes, it felt great running a MySQL command line in a buffer and copying all those long queries into a PHP file in another one, but most of the time I thought there could be a better way of doing some things, like simply moving the cursor around a document.

But my Emacs month wasn't just about what I thought the editor could do. I measured the time I used for common tasks and noticed I was way faster with Vim. Even simple things like correcting a syntax error on line 20 took longer with Emacs.

I do most of my editing via ssh links and my editor has to work as fast as possible, specially when I use my mobile connection, which is slower than the ADSL one. With Vim I could ssh to all my servers and work, with the same simple .vimrc I have in my local stations, smoother than with Emacs.

Vim can easily split the work area in windows, the equivalent of Emacs' buffers, use tabs and even save the whole environment as sessions I can recover later. Sessions are a nice way to avoid having to remember all the files I had open and where the cursor was positioned in each one. I'm sure that's possible with Emacs but it must be well hidden in the documentation.

Emacs' many ways of doing the same thing approach, in contrast to Vim's one simple way of doing one thing, can make it more complex in the long run.

Even accepting that it may be because I've used it so much, I have to conclude my favorite editor continues to be Vim. I don't stop every couple of minutes thinking how should I do this when using Vim, I just work. A good editor, following Amazon's reasoning for designing the Kindle, shouldn't get in your way, it has to be invisible and allow you to do what you need to do.

But don't get me wrong, I like Emacs and if Joy hadn't invented vi I would be using Emacs for everything. Emacs is, for me, in a very solid second position as a programmer's editor.

What good hackers should do?

Both Vim and Emacs are great applications. Whichever you choose you'll have a big advantage over those visual tools fellows who are in love with the sound of the mouse clicking. If you think you are real hacker, in the true MIT meaning of the word, you really need to consider either Vim or Emacs. Now, that's an absolute truth.

Recommended reading

Learning GNU Emacs

Learning Vim

Keep your comments relevant, written in good English and don't spam. Let's create useful and valuable discussions. Markdown is welcome.

Add your comment