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?
2 Answers
echo 'export EDITOR=vim' >> ~/.bashrc
-
also works for neovim with small change :
echo 'export EDITOR=nvim' >> ~/.bashrc
– bcag2Commented Jan 3, 2023 at 13:48
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.