Changing default editor for crontab from nano to vim

Problem

You would like to change the default editor for crontab from nano to vim.

Solution

Add the following to the ~/.selected_editor:

SELECTED_EDITOR="/usr/bin/vim"

or run the select-editor and choose vim-basic (4)

server# select-editor 

Select an editor.  To change later, run 'select-editor'.
  1. /bin/ed
  2. /bin/nano        <---- easiest
  3. /usr/bin/mcedit
  4. /usr/bin/vim.basic
  5. /usr/bin/vim.tiny

Choose 1-5 [2]: 4