How to change the default text editor on Linux
Posted on In QAOn Linux, a default editor is used for text editing such as crontab -e
or git commit
. How to change it to the editor of my own choice?
The default editor is indicated by the EDITOR
environment variable. You can set this environment variable to set the default editor. For example, set it to emacs by EDITOR=emacs
.
If you want to set it for all users, add this line to /etc/bashrc
or /etc/profile
:
export EDITOR=emacs
If you want to set it for yourself only, add this line to ~/.bashrc
or ~/.profile
:
export EDITOR=emacs
If you want to set it for one shell instance only, run this:
export EDITOR=emacs
If you want to set it for just one instance of a program, say crontabe -e
, run this:
EDITOR=emacs crontab -e