Literally dozens of text editors are available under Unix; writing one seems to be one of the standard finger exercises for budding open-source hackers. Most of these are ephemera, not suitable for extended use by anyone other than their authors. A few are emulations of non-Unix editors, useful as transition aids for programmers used to other operating systems. You can browse through a wide variety at SourceForge or ibiblio or any other major open-source archive.
For serious editing work, two editors completely dominate the Unix programming scene. Each is available in a couple of minor variant implementations, but has a standard version you can rely on finding on any modern Unix system. These two editors are vi and Emacs. We discussed them in Chapter 13 as part of our discussion of the right size of software.
As we noted in Chapter 13, these two editors express sharply contrasting design philosophies, but both are extremely popular and command great loyalty from identifiable core user populations. Surveys of Unix programmers consistently indicate about a 50/50 split between them, with all other editors barely registering.
In our earlier examinations of vi and Emacs, we were primarily concerned with their optional complexity and the surrounding design-philosophy issues. Many other things are worth knowing about these editors, both as a matter of practicality and of Unix cultural literacy.
The name of vi is an abbreviation for “visual editor” and is pronounced /vee eye/ (not /vie/ and definitely not /siks/!).
vi was not quite the earliest screen-oriented editor; that palm goes to the Rand editor, re, that ran on Version 6 Unix in the 1970s. But vi is the longest-lived screen-oriented editor built for Unix that is still in use, and is a hallowed part of Unix tradition.
The original vi was the version present in the earliest BSD software distributions beginning in 1976; it is now obsolete. Its replacement was ‘new vi’ which shipped with 4.4BSD and is found on modern 4.4BSD variants such as BSD/OS, FreeBSD, and NetBSD systems. There are several variants with extended features, notably vim, vile, elvis, and xvi; of these vim is probably the most popular and is found on many Linux systems. All the variants are rather similar and share a core command set unchanged from the original vi.
Ports of vi are available for the Windows operating systems and MacOS.
Most introductory Unix books include a chapter describing basic vi usage. One place a vi FAQ is available is the Editor FAQ/vi; you can find many other copies with a WWW keyword search for page titles including “vi” and “FAQ”.
The standard Emacs, universally available on modern Unixes, is GNU Emacs; this is what generally runs if you type emacs to a Unix shell prompt. GNU Emacs sources and documentation are available at the Free Software Foundation archive site.
The only major variant is called XEmacs; it has a better X interface but otherwise quite similar capabilities (it forked from Emacs 19). XEmacs has a home page. Emacs (and Emacs Lisp) is universally available under modern Unixes. It has been ported to MS-DOS (where it works poorly) and Windows 95 and NT (where it is said to work reasonably well).
Emacs includes its own interactive tutorial and very complete on-line documentation; you'll find instructions on how to invoke both on the default Emacs startup screen. A good introduction on paper is Learning GNU Emacs [Cameron].
The keystroke commands used in the Unix ports of Netscape/Mozilla and Internet Explorer text windows (in forms and the mailer) are copied from the stock Emacs bindings for basic text editing. These bindings are the closest thing to a cross-platform standard for editor keystrokes.