I am trying to tell my terminal to use vim instead of vi when editing crontab by executing export EDITOR=vim. But closing the terminal and opening a new one just resets the session. How do I change that?

echo 'export EDITOR=vim' >> ~/.bashrc

From the man page:

-e Edits the current crontab using the editor specified by the VISUAL or EDITOR environment variables.

Therefore unfortunately there is no crontab specific EDITOR setting, however, you could create an alias to invoke the vim editor prior to editing your cron:

alias crontabvim="export EDITOR=vim;crontab $@"

$@ will apply all subsequent arguments to the crontab command.

This can be saved in your ~/.bashrc file for session persistance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.