Changing your default editor on Linux

 
Published on 2010-10-01 by John Collins.

I find the keyboard shortcuts on VIM very difficult to grasp, and much prefer to use nano as my editor of choice from the Linux command line. Some commands however will automatically use the "default" editor on your system when invoked. For example the crontab edit command:

crontab -e

...will automatically open your crontab with your default editor, and by default on my system (Fedora) it is VIM. To change this to something else, you will need to open your bash profile in your home directory like so:

nano ~/.bashrc

Now add in the following line to the end of that file:

export EDITOR=nano

Note that you can use whatever editor you like here, I just like nano :-) Also note that this change will not take effect until you restart your shell session.


Updated 2021 : note that the above post was originally published in 2010, but is left here for archival purposes.