LinuxCommandLibrary

editor

TLDR

Open the default editor

$ editor [file.txt]
copy
Change default editor
$ sudo update-alternatives --config editor
copy
Set editor via environment
$ export EDITOR=vim
copy
Set visual editor
$ export VISUAL=nano
copy

SYNOPSIS

editor [file]

DESCRIPTION

editor is a symbolic link or alias to the system's default text editor. On Debian-based systems, it's managed by the alternatives system and typically points to nano, vim, or another installed editor.
The editor command provides a standard way for programs to invoke a text editor. Commands like crontab, visudo, and git commit use the EDITOR or VISUAL environment variables to determine which editor to launch.

CONFIGURATION

$ # Check current editor
update-alternatives --display editor

# Set default (Debian/Ubuntu)
sudo update-alternatives --config editor

# Set via environment
export EDITOR=vim
export VISUAL="code --wait"
copy

EDITOR PRIORITY

Programs typically check in order:
1. VISUAL (for graphical terminals)
2. EDITOR (for any terminal)
3. System default (editor, /usr/bin/editor)

CAVEATS

The editor command may not exist on all systems. Environment variables override system settings. Some programs ignore EDITOR and use their own configuration. Graphical editors need --wait or similar flag for proper integration.

SEE ALSO

Copied to clipboard