Stop Nano. How to edit Crontab using Vim

If you use Vim as every-day text editor on your *nix system, you could find an annoying behaviour in editing Crontab. Everytime you use the crontab command, you’re pushed into the Nano editor and you forced to use it.

 

Modify your shell configuration file to get Vim as Crontab editor

The solution is simple, you only need to update your shell configuration file to set Vim as default text editor for Crontab.

So, in your command line interface:

vi ~/.bashrc

A common thing to put in .bashrc are aliases that you want to always be available and you can also override the existing *nix default aliases.

You must include the following in your shell configuration file:

alias crontab=”export VISUAL=vim; crontab

Restart your CLI and then you can simply run the Crontab command as usually:

crontab -e

And now you’re able to edit the Crontab with Vim.

 

References

crontab - files used to schedule the execution of programs
Vim - the ubiquitous text editor
Bash Startup Files

Leave a Reply

Your email address will not be published. Required fields are marked *