5

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 2

7
echo 'export EDITOR=vim' >> ~/.bashrc
1
  • also works for neovim with small change : echo 'export EDITOR=nvim' >> ~/.bashrc
    – bcag2
    Commented Jan 3, 2023 at 13:48
0

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.