The Linux Page

crontab -e — change default editor, selected wrong editor

In Ubuntu 16.04, I wanted to add a user cron file with crontab -e, which has a new behavior: the very first time, it asks you what editor you want to use (i.e. nano, vim, ...)

If you choose the wrong one, then next time it does not ask you, it remembers your choice forever, so you'll be stuck.

The nano editor is okay, but difficult to work with if you're used to something like vim.

The data actually gets saved in a hidden file of your home directory named .selected_editor.

# Generated by /usr/bin/select-editor
SELECTED_EDITOR="/usr/bin/vim"

Mine was set to "/bin/nano" instead of "/usr/bin/vim". You can just edit this file or delete it and crontab -e will re-ask you.

There is probably another way to set this up for your entire system, although I have not looked for a different solution at this point.