Why Should You Use GNU Emacs Instead of Vi?
- GNU Emacs comes with a complete manual available online with a hypertext
viewing facility.
- GNU Emacs has numerous other help facilities: a tutorial; commands to
describe functions, variables, keybindings, major modes; commands to
look up commands, functions, and variables by patterns in their names.
- GNU Emacs does multiple windows even on dumb terminals. You can look
at many different places in one file in different windows. You can
split the screen horizontally or vertically, as many times as there is
space on the screen.
- GNU Emacs runs under several window systems and has mouse support.
- GNU Emacs has less mode confusion than vi, where you have to remember
whether or not you're in "insert" mode. New users find this less
confusing. (Please folks, don't try to tell people that Emacs is
"modeless". That's just plain false.) (Some versions of vi can be told
to display a string in the corner of the screen indicating which mode is
active.)
- GNU Emacs can edit an unlimited number of files simultaneously.
- GNU Emacs correctly edits binary files, including files with NUL
characters (ASCII code 0) and files with arbitrarily long lines (or no
newline characters at all).
- GNU Emacs displays the screen in an unambiguous manner; you can always
know where the line breaks are. (However, tab characters are not
unambiguously displayed! Arrgh!)
- GNU Emacs saves up-to-date "autosave" copies of files on which you are
working every 300 (user-configurable) keystrokes. It also does this
automatically if the terminal connection is lost.
- GNU Emacs keeps backup copies of files it saves, and can be told to keep
any number of older versions of a file.
- GNU Emacs provides unlimited undo capabilities. By default Emacs keeps
at least 15000 (user-configurable) and not more than 20000
(user-configurable) bytes worth of undo data per buffer. (Since undo
data is only discarded at garbage-collection time, you temporarily can
have much more undo data available.)
- GNU Emacs saves the last 30 (user-configurable) items you have deleted
for later recall.
- GNU Emacs automatically does locking on modified files and will warn
users trying to edit the same file. (WARNING: This has never been
fixed to work across NFS file systems.)
- GNU Emacs warns you if the file you are about to write has changed
since you read it in. When you work at multiple terminals or multiple
windows within a terminal, or when you work with other people on a
single source file, this can prevent you from trashing valuable
changes.
- GNU Emacs allows *all* of its keybindings to be changed.
- GNU Emacs has an extension language, Emacs Lisp, and in fact is
largely written in this language, so it is easy to change (and fix if
necessary).
- GNU Emacs has an interactive debugger for Emacs Lisp.
- GNU Emacs comes with source code so you aren't vulnerably dependent on
your vendor.
- GNU Emacs is free and can be shared with anyone.
- GNU Emacs provides a more complete software development environment.
For example, M-x compile, M-x grep, M-x shell, etc.
- After doing a M-x compile, GNU Emacs can parse the error messages in
the output and visit the appropriate lines of the appropriate files.
- GNU Emacs can record your keystrokes into keyboard macros.
- GNU Emacs provides many mechanisms to reduce your need to remember and
type long names. For example, abbrevs (abbreviations you define),
dynamic abbrevs (look for similar things already in the buffer),
program identifier completion, filename completion, etc.
- GNU Emacs provides major modes that are custom tailored for each
different editing need, for example: C, C++, Indented Text, Outline,
TeX, Nroff, etc.
- GNU Emacs Lisp packages have already been written to do almost any
imaginable task, so you don't need to.
- GNU Emacs or other Emacs variants are available on far more types of
computers than vi. In addition, more and more programs are using
Emacs-style keybindings. (This isn't necessarily a good thing, it
just means spending time in learning default Emacs key bindings can be
a good investment.)
- GNU Emacs comes on some Unix systems instead of vi. GNU Emacs will
come with the next release of BSD Unix.
- GNU Emacs comes with major modes to emulate vi. (vi can't emulate
Emacs.) (See the latest release of vip.el for the best vi emulation.)
- GNU Emacs has Shell mode. You can run shell commands in an Emacs
buffer, call up previous commands, cut and paste command output,
review results that have scrolled off the screen, etc.
- GNU Emacs has incremental search. This minimizes the number of keys you
need to press to find a string in a buffer. You can usually find the
exact occurrence of a 20 character identifier you are looking for in 5
or 6 keystrokes. You can also incrementally search for a regular
expression.
- GNU Emacs has superior, configurable, language sensitive indentation.
(vi has ":1,$!cb", but this is slower and less flexible.)
- GNU Emacs has "query replace". This is like a global search and
replace, except Emacs will show you each occurrence in its entire
context within the file and ask you what to do. You can even edit the
occurrence without interrupting the query replace operation.
- GNU Emacs has a spell checker.
- GNU Emacs can "fill" paragraphs, either manually or automatically. This
evens up the length of the lines. It will also right-justify.
- GNU Emacs has a status line for every window showing the file name,
relative position within the file, if the file is modified, etc. (This
is all user-configurable.)
- GNU Emacs has support for reading, composing, and sending e-mail and
news.
- GNU Emacs has rectangular cut and paste --- this works on columns of
text.
- GNU Emacs recognizes sentences and can cut and paste them. You can
change the patterns that are used to find the beginning and end of
sentences.
- GNU Emacs has Dired, a file directory editor.
- GNU Emacs updates the screen with every keystroke. (Some versions of vi
do not update deletes while in insert mode.)
- GNU Emacs will calculate a minimal cost sequence of characters to update
the screen on slow terminal lines. In addition, it checks whether input
is available before redrawing the screen, and if input is available it
processes it first to avoid unnecessary screen redrawing.
- GNU Emacs prompts for commands that need parameters; thus you don't need
to memorize syntax.
- GNU Emacs adjusts when a terminal emulator window in which is it running
is resized. (Many versions of vi don't.)
- GNU Emacs has real word wrapping.
There are also some reasons why you might prefer vi:
- vi comes with almost every Unix system, while GNU Emacs doesn't. (This
means you'll have to use vi while you're building and installing GNU
Emacs.)
- vi starts up much faster. With Emacs, you should keep an Emacs job
running all the time to avoid this problem. This can be a problem if
you don't have job control or a window system, or if you don't read your
e-mail or news with Emacs and you want to edit messages you're sending.
- At the single-user level, you may have to use vi or ed (which shares
much of vi's command syntax) because the file system containing Emacs
might not be available.
- vi fanatics claim that setting defaults for Emacs requires more
knowledge than for vi. I don't know whether this is true.
- The installed Emacs takes much more file space than vi.
- Emacs has no real equivalent to vi's "dot" repeat command.
- Emacs depends heavily on the availability of a Meta key. Otherwise,
pressing ESC all the time can be a pain.
- Some people have an irrational dislike for having to press either the
Control key or the Meta key to invoke commands.
- vi has a ":set list" command which will show you non-printable
characters, even TAB characters. In Emacs, there is no way to
distinguish between TAB and SPC characters without moving the cursor
over them.
- vi uses the tty's cooked mode editing characters in insert mode. This
means if you change the keys you use at the shell level, vi
automatically adjusts.
So how do you insert more than one character 70 times?
- vi handles arrow keys that generate ANSI key sequences by default. (Is
this true???? Does it read the termcap to find out what the terminal
uses????)
Page URL: http://www.d.umn.edu
/~tcolburn/emacs/emacs-vs-vi.html
Page Author: Tim Colburn
Last Modified: Wednesday, 25-Aug-1999 15:53:51 CDT
Comments to: tcolburn@d.umn.edu