Force crontab editor :: default editor
-
Many times you type:
crontab -e
And end up with key bindings your not used to. (h,j,k,i) As in vi or ed.
Say you normally use nano:
export VISUAL=nano; crontab -e
Boom, crontab will open and nano will be your editor.
Same goes for vi:
export VISUAL=vim; crontab -e
Then again maybe you want to use your preferred editor always, or as default.
Get a list of available editors currently install on your system by running:
update-alternatives --list editor
In this case, the output is:
/bin/ed /bin/nano /usr/bin/vim.gnome /usr/bin/vim.tiny
So you may combine the above for on demand usage such as:
export VISUAL=ed; crontab -e
Or:
export VISUAL=vim.gnome; crontab -e
ect…
To make one specific editor default to your users profile, you must edit:
~/.profile
So for example if your enjoying the ease of nano:
nano ~/.profile
And add these lines as follows:
EDITOR=nano VISUAL=$EDITOR export EDITOR VISUAL
Replacing in the above case ‘nano’ with your desired default editor.
When you run the following as root, you are changing the default editor system wide, or all users. In this case, we can use ‘editor’, to see which editors are currently available on the system, as well as priorities, paths, and status:
update-alternatives --config editor
The output will be:
Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/vim.gnome 60 auto mode 1 /bin/ed -100 manual mode 2 /bin/nano 40 manual mode 3 /usr/bin/vim.gnome 60 manual mode 4 /usr/bin/vim.tiny 10 manual mode Press enter to keep the current choice[*], or type selection number:
Then simply type the number of the default system wide editor you wish.