Editor war
The editor war is the rivalry between users of the Emacs and vi text editors. The rivalry has become a lasting part of hacker culture and the free software community.
The Emacs vs vi debate was one of the original "holy wars" conducted on Usenet groups, with many flame wars fought between those insisting that their editor of choice is the of editing perfection, and insulting the other, since at least 1985. Related battles have been fought over operating systems, programming languages, version control systems, and even source code indent style.
Comparison
The most important historical differences between vi and Emacs are presented in the following table:Feature | Emacs | vi |
Keystroke execution | Emacs commands are key combinations for which modifier keys are held down while other keys are pressed; a command gets executed once completely typed. This still forms a decision tree of commands, but not one of individual keystrokes. A vim-inspired Emacs package provides a user interface to the tree. | vi retains each permutation of typed keys. This creates a path in the decision tree which unambiguously identifies any command. |
Memory usage and customizability | Emacs executes many actions on startup, many of which may execute arbitrary user code. This makes Emacs take longer to start up and require more memory. However, it is highly customizable and includes a large number of features, as it is essentially an execution environment for a Lisp program designed for text-editing. Emacs 18 introduced a server mode designed to run continuously in the background. Various instances of Emacs can then be started in client mode, attaching to this server and sharing state. Emacs client startup time is practically instantaneous as all it does is provoke the existing Emacs process to redraw the display. | vi is a smaller and faster program, but with less capacity for customization. vim has evolved from vi to provide significantly more functionality and customization than vi, making it comparable to Emacs. vi start-up time is near instantaneous for small text files, while vim is almost as fast. |
User environment | Emacs, while also initially designed for use on a console, had X11 GUI support added in Emacs 18, and made the default in version 19. Current Emacs GUIs include full support for proportionate spacing and font-size variation. Emacs also supports embedded images and hypertext. | vi, like emacs, was originally exclusively used inside of a text-mode console, offering no graphical user interface. Many modern vi derivatives, e.g. MacVim and gVim, include GUIs. However, support for proportionally spaced fonts remains absent. Also lacking is support for different sized fonts in the same document. |
Function/navigation interface | Emacs uses metakey chords. Keys or key chords can be defined as prefix keys, which put Emacs into a mode where it waits for additional key presses that constitute a key binding. Key bindings can be mode-specific, further customizing the interaction style. Emacs provides a command line accessed by M-x that can be configured to autocomplete in various ways. Emacs also provides a macro, allowing alternate names for commands. | vi uses distinct editing modes. Under "insert mode", keys insert characters into the document. Under "normal mode", bare keypresses execute vi commands. |
Keyboard | The expansion of one of Emacs' backronyms is Escape, Meta, Alt, Control, Shift, which neatly summarizes most of the modifier keys it uses, only leaving out Super. Emacs was developed on Space-cadet keyboards that had more key modifiers than modern layouts. There are multiple emacs packages, such as spacemacs or ergoemacs that replace these key combinations with ones easier to type, or customization can be done ad hoc by the user. | vi does not use the key and seldom uses the key. vi's keyset is mainly restricted to the alphanumeric keys, and the escape key. This is an enduring relic of its teletype heritage, but has the effect of making most of vi's functionality accessible without frequent awkward finger reaches. |
Language and script support | Emacs has full support for all Unicode-compatible writing systems and allows multiple scripts to be freely intermixed. | vi has rudimentary support for languages other than English. Modern Vim supports Unicode if used with a terminal that supports Unicode. |
Benefits of Emacs
- Emacs has a non-modal interface
- One of the most ported computer programs. It runs in text mode and under graphical user interfaces on a wide variety of operating systems, including most Unix-like systems, MS-DOS, Microsoft Windows, AmigaOS, and OpenVMS. Unix systems, both free and proprietary, frequently provide Emacs bundled with the operating system.
- Emacs server architecture allows multiple clients to attach to the same Emacs instance and share the buffer list, kill ring, undo history and other state.
- Pervasive online help system with keybindings, functions and commands documented on the fly.
- Extensible and customizable Lisp programming language variant, with features that include:
- * Ability to emulate vi and vim.
- * A powerful and extensible file manager, integrated debugger, and a large set of development and other tools.
- * Having every command be an Emacs Lisp function enables commands to DWIM by programmatically responding to past actions and document state. For example, a
switch-or-split-window
command could switch to another window if one exists, or create one if needed. This cuts down on the number of keystrokes and commands a user must remember. - * "An OS inside an OS". Emacs Lisp enables Emacs to be programmed far beyond editing features. Even a base install contains several dozen applications, including two web browsers, news readers, several mail agents, four IRC clients, a version of ELIZA, and a variety of games. All of these applications are available anywhere Emacs runs, with the same user interface and functionality. Starting with version 24, Emacs includes a package manager, making it easy to install additional applications including alternate web browsers, EMMS, and more. Also available are numerous packages for programming, including some targeted at specific language/library combinations or coding styles.
- Non-modal nature of Emacs keybindings makes it practical to be supported as an OS-wide keybindings.
Benefits of vi
- Edit commands are composable
- Vi has a modal interface
- Vi loads faster than Emacs.
- Being deeply associated with UNIX tradition, it runs on all systems that can implement the standard C library, including UNIX, Linux, AmigaOS, DOS, Windows, Mac, BeOS, OpenVMS, IRIX, AIX, HP-UX, BSD and POSIX-compliant systems.
- Extensible and customizable through Vim script or APIs for interpreted languages such as Python, Ruby, Perl, and Lua
- Ubiquitous. Essentially all Unix and Unix-like systems come with vi built-in. Vi is specified in the POSIX standard.
- System rescue environments, embedded systems and other constrained environments often include vi, but not emacs.
Evolution
Tim O'Reilly said, in 1999, that O'Reilly Media's tutorial on vi sells twice as many copies as that on Emacs. Many programmers use either Emacs and vi or their various offshoots, including Linus Torvalds who uses MicroEMACS. Also in 1999, vi creator Bill Joy said that vi was "written for a world that doesn't exist anymore" and stated that Emacs was written on much more capable machines with faster displays so they could have "funny commands with the screen shimmering and all that, and meanwhile, I'm sitting at home in sort of World War II surplus housing at Berkeley with a modem and a terminal that can just barely get the cursor off the bottom line".
In addition to Emacs and vi workalikes, pico and its free and open-source clone nano and other text editors such as ne often have their own third-party advocates in the editor wars, though not to the extent of Emacs and vi.
, both Emacs and vi can lay claim to being among the longest-lived application programs of all time, as well as being the two most commonly used text editors on Linux and Unix. Many operating systems, especially Linux and BSD derivatives, bundle multiple text editors with the operating system to cater to user demand. For example, a default installation of macOS contains Emacs, ed, nano, TextEdit, and Vim. Frequently, at some point in the discussion, someone will point out that ed is the standard text editor.
Humor
The Church of Emacs, formed by Emacs and the GNU Project's creator Richard Stallman, is a parody religion. While it refers to vi as the "editor of the beast", it does not oppose the use of vi; rather, it calls proprietary software anathema. The Church of Emacs has its own newsgroup, alt.religion.emacs, that has posts purporting to support this belief system.Stallman has referred to himself as St IGNU−cius, a saint in the Church of Emacs.
Supporters of vi have created an opposing Cult of vi, argued by the more hard-line Emacs users to be an attempt to "ape their betters".
Regarding vi's modal nature some Emacs users joke that vi has two modes – "beep repeatedly" and "break everything". vi users enjoy joking that Emacs's key-sequences induce carpal tunnel syndrome, or mentioning one of many satirical expansions of the acronym EMACS, such as "Escape Meta Alt Control Shift". or "Eight Megabytes And Constantly Swapping" or "EMACS Makes Any Computer Slow" or "Eventually Munches All Computer Storage", in reference to Emacs's high system resource requirements. GNU EMACS has been expanded to "Generally Not Used, Except by Middle-Aged Computer Scientists" referencing its most ardent fans, and its declining usage among younger programmers compared to more graphically-oriented editors such as TextMate. The Emacs distribution includes the full list.
As a poke at Emacs' creeping featurism, vi advocates have been known to describe Emacs as "a great operating system, lacking only a decent editor". Emacs advocates have been known to respond that the editor is actually very good, but the operating system could use improvement.
A game among UNIX users, either to test the depth of an Emacs user's understanding of the editor or to poke fun at the complexity of Emacs, involved predicting what would happen if a user held down a modifier key and typed their own name. This game humor originated with users of the older TECO editor, which was the implementation basis, via macros, of the original Emacs.
Due to the unintuitive character sequence to exit vi, hackers joke about a proposed method of creating a pseudorandom character sequence by having a user unfamiliar with vi seated in front of an open editor and asking them to exit the program.