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, 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.

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

echo $EDITOR

You'll likely want to set these variables in your profile, $HOME/.profile, so that they're set whenever you log in. For more information, see "$HOME/.profile" in Configuring Your Environment.