In a world where both software and hardware frequently become obsolete right on release, two rival programs can stake a claim to being among the longest-lived applications of all time. Both programs are about to enter their fifth decades. Both programs are text editors, for inputting and editing code, data files, raw HTML Web pages, and anything else. And they are mortal enemies.
Their names are Emacs and Vi (styled by programmers as “vi”). These editors are legendary and ancient, no exaggeration. Both date back to at least 1976, making them older than the vast majority of people currently using them. Both programs are text editors, which means they are not WYSIWYG (what you see is what you get)—unlike, say, word processors like Microsoft Word, they do not format your words onscreen. Programming is very different from word processing, and the basic goal of Emacs and Vi—fast editing of source code (and any other text files)—has yet to become obsolete. Both have been in ongoing development for almost 40 years.
These two wizened programs are as close to equally matched enemies as any two programs have ever been. If you know a programmer who uses one of them, there’s a good chance that she hates the other. I’ve stuck with Emacs for most of my career; my wife prefers to use Vim, a popular Vi clone that stands for “VI iMproved.” We don’t talk about it, lest we become casualties of the so-called Editor War.
The oppositions don’t stop there. Vi was developed by the legendary Bill Joy (who went on to found Sun Microsystems and create Java) while a grad student at Berkeley. It was later included as a closed-source program in most Unix operating systems, though open-source clones have existed since the mid-1980s and dominate today. Emacs got its start all the way across the country at MIT, a project by Guy Steele and Richard Stallman, but it only gained prominence when the equally legendary Stallman developed a much more powerful variant, GNU Emacs, in the mid-1980s as part of the free software movement that Stallman spearheaded.* While Vi remained small and slick, Emacs embraced extensibility and epic size. (Emacs, a joke goes, stood for “Emacs Makes a Computer Slow” and “Eight Megabytes and Constantly Swapping” back when 8 megabytes was a huge amount of memory.) Emacs was so flexible that it could even alter its interface and behavior to look and act exactly like Vi, if you really wanted.
Vi haters say you only need to know one command—the three-character combo “:q!”—because that’s the quit command. I was baffled the first time I used Vi because I couldn’t even figure out how to enter text. Typing just produced a series of beeps. The arrow keys did nothing. And of course I didn’t know the command to quit. A classmate explained what was up, which was that Vi starts up in “normal mode,” which rather abnormally does not allow for entering new text but only editing of existing text. You have to type “i” to go into “insert mode,” which will allow you to type freely. Hit the Esc key and you’re back in normal mode, where I typed “:q!,” my other piece of new knowledge, and disconcertedly switched back to Emacs.
That brutal introduction is representative of Vi’s learning curve, as depicted in this chart. The upside is that mastering Vi’s arcane command set yields a powerful and lightning-fast editor. I suspect that expert Vi users are capable of making manual edits faster than people in any other program, not just because the command sequences are so cryptically compressed, but because Vi itself has very low overhead, responding instantly to almost any task you set it to. It is unmatched at what programmer Larry Marburger terms text surgery. Jump back five words? “5b”! Delete the next six lines? “d6j”! Search for the next instance of whatever word the cursor happens to be on? “*”! Put quotation marks around every line in a file? Eighteen keystrokes: “:%s/\(^\|$\)/”/g”
Coincidentally, these are also the obscenicons of the reaction most people will have when they see that set of commands. I’m rusty, so it took me a few minutes to create that combo, but a Vi veteran could come up with it in seconds. (Really.)
Vi was written for a time when computers were slow enough that you didn’t want anything causing unnecessary delays—like extra keystrokes or graphical niceties. Joy tailored it for computers that had net connections that printed out text slower than people could read. As Joy said in 1999, “I was trying to make it usable over a 300 baud modem … the editor was optimized so that you could edit and feel productive when it was painting slower than you could think.” But even now that unparalleled efficiency has its adherents among people who are driven mad by the slightest delay in their productivity. (For example, software engineers.) Vi is one of the few programs you can use without moving your hands from their default touch-typing position: You don’t even need the arrow keys (that’s what H, J, K, and L are for).
Emacs, on the other hand, offers a far more conventional and accessible editing environment, with commands based on reasonably intuitive combinations: Ctrl-S lets you search, Ctrl-X Ctrl-S saves the file to disk, and so on. The program provides more feedback to the user and is less prone to beeping rudely at novices than Vi. It does lovely text formatting and has lots of helpful features for coders in many, many languages.
But Emacs would be nothing special if it stopped there. Where Emacs excels is in its flexibility. You can customize everything. For example, most command sequences begin with the Esc key or the Ctl key, including the Esc-X sequence that gets you to a searchable, autocomplete list of all commands. But those two keys are murder on your pinkies, and programmers have specifically blamed them for repetitive strain injury; my left pinky is getting a twinge even as I write this. But it doesn’t have to be a problem, since Emacs lets you remap key bindings with ease, so you can change the Ctl key to the caps lock key and Esc to the Alt key. Beyond that, pretty much any command can be mapped to any key or key combination. Programmers can customize Emacs down to the tiniest detail to serve their particular needs. God help the schmoe who tries to use your Emacs, but that’s not your problem … until you’re stuck on someone else’s machine.
Emacs has its own internal programming language, a variant of LISP, that allows you to program all sorts of functionality into the editor: not just text editing and formatting functionality, but really anything, be it a file system, a clock, a Web browser, text adventures, instant messaging, and so on, to the point that you really can do most of your daily business in Emacs if you so choose, as certain Emacs fans I know have done—you never have to switch windows! Emacs offers a much gentler initial learning curve than Vi, but the curve never ends, only spiraling into increasing complexity. The endless possibilities of Emacs can consume your life and productivity.
So the broad outline of the two warring programs should be clear. On the one hand, the austere elegance of Vi, which allows programmers to achieve trancelike focus while moving their fingers as little as possible. On the other, the all-encompassing, flexible universe of Emacs, which you can customize and extend until it meets your most idiosyncratic requirements. Vi’s standardized perfection and Emacs’ abstract generality are two of the highest ideals of engineers. The war between the two programs should tell you that these ideals are often not quite compatible.
Sometimes it boils down to people’s personalities: whether they prefer to bend to a rigid but popular system (like Vi) or to create a singular environment for themselves (with Emacs). Tim O’Reilly, of O’Reilly Media, switched to Vi after his customized Emacs setup had inadvertently been destroyed. He decided to follow the “cult of Vi,” praising Vi’s ubiquity: “It was just there on any system I sat down at.” (Still, he said, “I don’t want to pour gasoline on this fire.”) Linux inventor Linus Torvalds, on the other hand, not only prefers Emacs (a somewhat stripped-down variant called MicroEmacs, to be precise), but has even modified the underlying code to make it even more suited to his particular needs.
While Emacs can emulate Vi (to a point), it can’t catch up to it. Even the biggest Vi detractor will not dispute that it’s faster than Emacs. (The Vi fanatic will say that you can learn the Vi command set in the time it takes for Emacs to start up.) Make no mistake, Emacs is still considerably faster than a graphical editor like Eclipse or Microsoft Visual Studio, but Vi partisans see no reason to sacrifice any efficiency to Emacs’ bloat. The Emacs fan will respond that you start up Emacs just once and leave it running, preferably forever. Let Emacs become your operating system.
But any programmer will sometimes have to make edits on a different system, possibly even one without Emacs installed (horrors!), and at those times Emacs is a 16-ton weight attached to your shoes. So many Emacs users will grudgingly learn the basics of Vi to use in a pinch. In turn, Vi’s narrowness has softened over the years, as it has taken on more features and more extensions to the point where, in its more powerful clones like Vim, it offers a good number of Emacs’ more popular and mainstream editing features (as well as Tetris).
So the two enemies have gradually moved a bit toward convergence. The preference for one over the other is frequently not practical but philosophical and aesthetic: Which ideal, focus or flexibility, is closer to your heart? Which would you save first from a burning house? Engineering is in large part the art of coping with imperfection and incompatibility, and the compromises made are not purely utilitarian, but reveal a particular engineer’s sense of what is the most beautiful option—or more frequently, the least ugly.
Correction, June 18, 2014: This article originally stated that Richard Stallman spearheaded the open-source software movement. Stallman started the free software movement. (Return.)