Specifying the default editor

Some system processes ask you to use an editor to provide some information. For example, if you check something into a version-control system such as CVS, you're asked to explain the changes you made. Such processes use the VISUAL or EDITOR environment variable—or both—to determine which editor to use; the default is vi.

Historically, you used EDITOR to specify a line-oriented editor, and VISUAL to specify a fullscreen editor. Applications might use one or or both of these variables. Some applications that use both use VISUAL in preference to EDITOR when a fullscreen editor is required, or EDITOR in preference to VISUAL when a line-oriented editor is required.

Few modern applications invoke line-oriented editors, and few users set EDITOR to one, so you can't rely on applications to give preference one way or the other. For most uses, we recommend that you set VISUAL and EDITOR to the same value.

Once you've tried various editors, you can set these environment variables so that your favorite editor becomes the default. At the command-line prompt, type:

export VISUAL=path
export EDITOR=path

where path is the path to the executable for the editor. For example, if you want to use jed as the default editor, type:

$ which jed
/usr/local/bin/jed
$ export VISUAL=/usr/local/bin/jed
$ export EDITOR=/usr/local/bin/jed

To check the value of the EDITOR environment variable, type:

echo $EDITOR