Some publications mention a holy war between users of Vim and Emacs but I don't think war is the right word and refuse to even comment about the holy part. War is something that stupid people do. We, good programmers, are not stupid. Period.
Emacs and Vim are powerful editors for powerful users (and you're one of those aren't you?), useful tools that allow us writing and modifying code faster. Both can be used as word processors, I do all of my writing with Vim, including this article and my next book. Emacs goes even further providing an environment for doing much more than just editing text.
Programming tools and languages are very subjetive choices. Some get used to a set of tools and stick to them, even if new or better options appear. I prefer being open, if there's some alternative that could make me work faster and better I spend some time learning about it, and by some time I mean anything from a few hours to some weeks. It's a logical investment in useful knowledge.
I've written this three parts article to help you in making the right decision about the right editor. It's a very important one, specially if you spend eight or more hours a day swimming in code. My focus will be on productivity for programmers.
In this first part I'll talk about Emacs, the second installment will be focused on Vim and I'll conclude the series with some ideas on which editor I think you should choose for your programming tasks. All of this, of course, based on my own experience so your mileage may vary.
If you are already a Vim or Emacs user, I don't intend to change your mind but taking a look at the other side and comparing won't hurt, you may even get a little inspiration. If you don't use either yet and consider yourself a smart programmer this may be the time to give one of these guys a try.
Emacs is more than a text editor, it's an environment where you can not only hack code but also compile, manage files, access the shell and interface with your database server, to name just a few. I really like this part of Emacs, having everything in one place can boost your productivity as you don't need to jump between applications. I was able to run queries in psql while running tests in iPython and editing some Django templates, all inside Emacs.
Every file you open or task you run on Emacs uses a space of the main window known as a buffer. Everything on an Emacs's buffer can be edited, quite helpful if you want to copy that finely crafted SQL from psql to your Drupal's module.
Most commands in Emacs use key chords that involve the Control and Meta (Alt in most modern keyboards) keys. Some become obvious after a few hours using them (like CTRL+x CTRL+s for saving or CTRL+g for cancelling) but others can twist your fingers in sick ways, like the often used directional key chords. Why in hell did the Emacs guys choose CTRL+n, CTRL+p, CTRL+f and CTRL+b for these basic and common actions? Even if Emacs allows me to map keys as I please I expect the tool to work as best a possible out of the box.
Search and replace work fast and are easy to run, including support for regular expressions, but I don't like the way used to repeat these operations, something often needed when you find you used the wrong function call or variable name all over your code.
Configuration is perhaps where Emacs really shines like no other editor. You can completely change the way Emacs works if you've got the time, the patience and the coffee. The configuration file usually resides at ~/.emacs and its written in Lisp, yes, the Latin of programming languages usually known by its artificial intelligence applications. Don't be afraid of Lisp, you can learn a good deal of it, at least enough to setup Emacs, following GNU's introduction to programming in Emacs Lisp. Lisp is a fun and powerful language, different to what most programmers from the 21st century are used to, but still important to know.
Emacs includes very well written documentation and you can start learning with its tutorial by just pressing CTRL+h t. The first few screens are vital to know how to correctly navigate the help files.
Now, if you really want to become an Emacs jedi, ninja or whatever, O'Reilly's Learning GNU Emacs, now in its third edition, seems to me one of the best choices.
I really like Emacs, it's a well thought editor and I have no doubt is powerful enough to handle most of your programming needs; however, its complex key chords and their trying to be so many things at once turn it into a bigger than needed beast at times. Emacs is pretty fast on any modern computer for local use but I felt it a little slow over some of the ssh connections I use on my daily work.
I'm sure many of you will have different ideas about Emacs and I'd like you to share them. Is Emacs your favorite editor? How long have you been using it and what's the Emacs feature you enjoy the most?
Now, for something completely different, I'll take a look at Vim in the next part of the series.