Setting your preferred editor
Linux and in fact all Unix-like systems allow you to set your preferred editor via the EDITOR
environment variable. Most command-line software that launches an editor for certain tasks, like git
when you make a commit or visudo
editing your sudoers file, will use this variable to know which editor to open. You can set this EDITOR
variable to a path to any editor you like, even graphical ones (provided your system has a graphical user interface installed):
bash-3.2$ echo $EDITOR
nano
bash-3.2$ export EDITOR=vim
Note that the interactive shell command above will only work until the current shell session is closed; to persist this setting in the Bash shell, I’d add it to my ~/.bashrc
file. See Chapter 4, Using Shell History for more details.