The Linux Editors

This chapter is based on Chapters 9 through 12 of the Siever book, Linux in a Nutshell [Siever 2003] .

Linux has a surprisingly large number of available editors, many of them inherited from UNIX. Figure 1 illustrates some of them.

Editor Description
ed Original UNIX line-based editor, useful in scripts
emacs GNU editor and fully integrated user environment
ex Powerful line-based editor (integrated with vi)
gawk GNU awk, powerful text editor for records containing fields
sed Stream-oriented (non-interactive) line-based editor
vi Classic screen-based editor for UNIX
vim Vi IMproved, enhanced support for programmers

Figure 1: Some Linux editors

Some distributions have vim as the default version of vi, e.g. Red Hat Linux. This brief overview will concentrate on the two important screen-based editors that are shipped with Linux distributions. For information on the other editors, consult the relevant man pages.

The Emacs Editor

Emacs is more than "just an editor" -- it provides a fully integrated user environment offering the sort of facilities outlined below.

Emacs has a vast number of editing modes, which create an environment designed for the type of editing you are doing. There are two types of modes, major and minor.

Major Modes

These include modes for various programming languages (e.g. Bash, C, Lisp, and Perl), for text processing (e.g. Latex, SGML, troff, and plain text), and even Dired (Directory Editor) for managing directories.

Minor Modes

These allow you to set or unset features that are independent of the major mode, e.g. auto-fill (word wrapping), insert vs overwrite, and auto-save.

If you spend a lot of time editing files with a particular structure, then a customised version of emacs will pay real dividends by reducing the number of keystrokes needed to complete a specific task. For more information, see Learning GNU Emacs [Cameron 1996] .

The Vi Editor

This is the classic screen-based editor for UNIX. Apart from vim, there are a number of enhanced versions of vi, including elvis, nvi, and vile. The vi editor works in two modes, command and insert. This is attractive for users who separate text entry from editing.

Command mode

Once a file is opened, you are in command mode. This provides the following facilities.

Insert mode

You enter new text in the file (e.g. append, insert, overwrite, or substitute) and then press Esc to return to command mode. For more information, see Learning the vi Editor [Lamb 1998] .

References

  1. Debra Cameron, Bill Rosenblat, & Eric Raymond, Learning GNU Emacs (second edition), O'Reilly & Associates, Inc., Sebastopol, CA, September 1996, ISBN 1-56592-152-6.
  2. Linda Lamb & Arnold Robbins, Learning the vi editor (sixth edition), O'Reilly & Associates, Inc., Sebastopol, CA, November 1998, ISBN 1-56592-426-6.
  3. Ellen Siever, Stephen Figgins & Aaron Weber, Linux in a Nutshell (fourth edition), O'Reilly & Associates, Inc., Sebastopol, CA, June 2003, ISBN 0-596-00482-6.


Last modified: Mon Dec 5 12:50:26 2005