How to change the default text editor on Linux

On 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?

asked Mar 20, 2014 by Eric Z Ma (44,280 points)

1 Answer

 
Best answer

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
answered Mar 20, 2014 by Eric Z Ma (44,280 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...