Change default text editor for crontab to vim
I'm using ubuntu 9.10 and the default text editor is nano, which i hate. (doesn't everyone?)
Normally it's not a problem as i just vi or gedit everything but crontab -e
is opening with nano. I tried changing it to vim using sudo update-alternatives --config editor
and selecting option 3 ("/usr/bin/vim.basic"). This has changed it for sudo and non-sudo alike. But crontab -e
still opens nano. Any ideas? max
The crontab -e
command will check the environment variables $EDITOR
and $VISUAL
for an override of the default text editor, so...
export VISUAL=vim
or
export EDITOR=vim
should do the trick.
In ubuntu, try run: select-editor
, which interactively creates ~/.selected_editor
:
# Generated by /usr/bin/select-editor
SELECTED_EDITOR="/usr/bin/vim.basic"
If you hate nano
so much you can just uninstall it:
sudo apt-get remove nano
crontab
should then just default to the next EDITOR
(for me it was vim.basic
).
From man crontab
:
The -e option is used to edit the current crontab using the editor specified by the VISUAL or EDITOR environment variables. After you exit from the editor, the modified crontab will be installed automati‐ cally. If neither of the environment variables is defined, then the default editor /usr/bin/editor is used.
Add to your ~/.bashrc
:
export EDITOR=vim