Why Should You Use GNU Emacs Instead of Vi?

  1. GNU Emacs comes with a complete manual available online with a hypertext viewing facility.
  2. 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.
  3. 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.
  4. GNU Emacs runs under several window systems and has mouse support.
  5. 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.)
  6. GNU Emacs can edit an unlimited number of files simultaneously.
  7. 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).
  8. 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!)
  9. 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.
  10. GNU Emacs keeps backup copies of files it saves, and can be told to keep any number of older versions of a file.
  11. 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.)
  12. GNU Emacs saves the last 30 (user-configurable) items you have deleted for later recall.
  13. 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.)
  14. 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.
  15. GNU Emacs allows *all* of its keybindings to be changed.
  16. 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).
  17. GNU Emacs has an interactive debugger for Emacs Lisp.
  18. GNU Emacs comes with source code so you aren't vulnerably dependent on your vendor.
  19. GNU Emacs is free and can be shared with anyone.
  20. GNU Emacs provides a more complete software development environment. For example, M-x compile, M-x grep, M-x shell, etc.
  21. 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.
  22. GNU Emacs can record your keystrokes into keyboard macros.
  23. 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.
  24. GNU Emacs provides major modes that are custom tailored for each different editing need, for example: C, C++, Indented Text, Outline, TeX, Nroff, etc.
  25. GNU Emacs Lisp packages have already been written to do almost any imaginable task, so you don't need to.
  26. 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.)
  27. GNU Emacs comes on some Unix systems instead of vi. GNU Emacs will come with the next release of BSD Unix.
  28. 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.)
  29. 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.
  30. 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.
  31. GNU Emacs has superior, configurable, language sensitive indentation. (vi has ":1,$!cb", but this is slower and less flexible.)
  32. 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.
  33. GNU Emacs has a spell checker.
  34. GNU Emacs can "fill" paragraphs, either manually or automatically. This evens up the length of the lines. It will also right-justify.
  35. 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.)
  36. GNU Emacs has support for reading, composing, and sending e-mail and news.
  37. GNU Emacs has rectangular cut and paste --- this works on columns of text.
  38. 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.
  39. GNU Emacs has Dired, a file directory editor.
  40. GNU Emacs updates the screen with every keystroke. (Some versions of vi do not update deletes while in insert mode.)
  41. 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.
  42. GNU Emacs prompts for commands that need parameters; thus you don't need to memorize syntax.
  43. GNU Emacs adjusts when a terminal emulator window in which is it running is resized. (Many versions of vi don't.)
  44. GNU Emacs has real word wrapping.

There are also some reasons why you might prefer vi:

  1. 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.)
  2. 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.
  3. 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.
  4. vi fanatics claim that setting defaults for Emacs requires more knowledge than for vi. I don't know whether this is true.
  5. The installed Emacs takes much more file space than vi.
  6. Emacs has no real equivalent to vi's "dot" repeat command.
  7. Emacs depends heavily on the availability of a Meta key. Otherwise, pressing ESC all the time can be a pain.
  8. Some people have an irrational dislike for having to press either the Control key or the Meta key to invoke commands.
  9. 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.
  10. 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?
  11. 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