26

I would like to edit crontab with vi once. My default editor is nano, and I want to keep it that way. I only want to edit with vi one time. I don't want to change the default to vi then back to nano after editing. Can this be done?

D. Clancy
  • 261

2 Answers2

34

crontab should respect the EDITOR environment variable, so you can just do (for the root crontab for example)

sudo EDITOR=vi crontab -e

From man crontab

The -e option is used to edit the  current  crontab  using  the  editor
specified  by  the  VISUAL  or EDITOR environment variables.  
steeldriver
  • 142,475
8

Specifying nano as the editor for crontab file

export VISUAL=nano

Specifying vim as the editor for crontab file

export VISUAL=vim
  • now, just try it: crontab -e
PYK
  • 321