These two editors have long been considered the contenders in the
holy war of Emacs versus Vi. Despite the two group's tendency
to harass each other, research in classrooms where both were taught has
shown a nearly even split in which editor students eventually
preferred, even when they had facility in both. In normal situations,
people tend to stick to whichever they learned first. For those
who do know both, emacs and vi tend to often both be used, often
at the same time, taking advantage of their differences.
The differences for starting users:
has a basic command set (keys to hit to do things) which is largely
based on mnemonics like n for
Next, p for
previous, and relies on modifier keys like control, meta, and so
forth to distinguish commands from actual text being entered.
The emacs command set flexes very well across different keyboard layouts,
like qwerty versus dvorak, since commands aren't arranged by keyboard
position. However, there must be a convenient control key for emacs
to be usable. The emacs command set, actually a set of keybindings to
the underlying commands, is mostly mnemonic but give a bit of an impression
of having grown organically rather than having been planned.
Emacs has long been able to edit raw binary data, although
it once had difficultly with files more than several (8? 24?) megabytes
Emacs is especially convenient for users who like to edit multiple files
in one editor with multiple windows visible simultaneously, although
by no means restricted to such use.
VI has a basic command set with is significantly based on a row of
four keys on the keyboard, one which is not the right-hand
home row of
jkl; but rather shifted one key to the left. This
can be irritating to touch typists and difficult on dvorak keyboards,
since the basic key row in qwerty isn't a row in dvorak.
Vi relies on mode switching to distinguish commands from text entry,
with several single-letter commands to enter modes, and the escape key
used to return to command mode. Vi expects that there is an easily
usable escape key, although several work arounds are possible if
a control key is present. The vi command keys are a bit cryptic, but
give an impression of being planned out and are fairly self-consistent.
As of 2010, vi still has trouble with binary (non-text) files,
although this is a niche use.
Vi is especially convenient for quick edits of files with line-oriented
data, although by no means restricted to such use.
Emacs and Vi editing commands compared
|Emacs command||Function||vi command|
|Control-B||Move back one character||h|
|Control-F||Move forward one character||l|
|Control-P||Move to previous line||j|
|Control-N||Move to next line||k|
|Control-A||Move to start of line||^ or 0|
|Control-E||Move to end of line||$|
|Meta-B ||Move back one word||b|
|Meta-F ||Move forward one word||w|
|Control-V||Move to next page||Control-F|
|Meta-V ||Move to previous page||Control-B|
|Meta-<||Move to start of file||1G|
|Meta->||Move to end of file||G|
|Meta-D ||Delete word||dw|
|Control-K||Kill (delete) to end of line||d$|
|Control-Y||Yank (paste) killed text||Y or yy|
|Control-X Control-F||Read file||:r|
|Control-X Control-S||Save file||:w|
|Control-X Control-C||Exit||:q or :q! or :wq or ZZ|