Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using ubuntu 9.10 and the default text editor is nano, which i hate. (doesn't everyone?)

Normally it's not a problem as i just vi or gedit everything but crontab -e is opening with nano. I tried changing it to vim using sudo update-alternatives --config editor and selecting option 3 ("/usr/bin/vim.basic"). This has changed it for sudo and non-sudo alike. But crontab -e still opens nano. Any ideas? max

share|improve this question

6 Answers 6

up vote 64 down vote accepted

The crontab -e command will check the environment variables $EDITOR and $VISUAL for an override of the default text editor, so...

export VISUAL=vim


export EDITOR=vim

should do the trick.

share|improve this answer
yup, EDITOR works. Thanks! – Max Williams May 12 '11 at 9:32

In ubuntu, try run: select-editor

share|improve this answer
i tried this (under sudo and my user) and whatever option i changed, when i called it again it was still on nano. Fixed it anyway with EDITOR env var but thought i'd better mention it anyway. Cheers – Max Williams May 12 '11 at 9:34
Above answers didn't work...this does. – mlissner Jan 25 '13 at 19:59
This was gold! thanks. – saintali May 16 '13 at 8:50
Yup, this changes ~/.sensible_editor used by /usr/bin/sensible-editor. It seems that in the absence of the environment variables specifying the editor, crontab runs sensible-editor not editor as the former allows per-user configuration. – eel ghEEz Feb 25 at 5:25
@MaxWilliams, running select-editor will not show the previously made selection, which is stored in ~/.sensible_editor. – eel ghEEz Feb 25 at 5:27

From man crontab:

The -e option is used to edit the  current  crontab  using  the  editor
specified  by  the  VISUAL  or EDITOR environment variables.  After you
exit from the editor, the modified crontab will be installed  automati‐
cally.  If  neither  of  the environment variables is defined, then the
default editor /usr/bin/editor is used.

Add to your ~/.bashrc:

export EDITOR=vim
share|improve this answer

If you hate nano so much you can just uninstall it:

sudo apt-get remove nano

crontab should then just default to the next EDITER (for me it was vim.basic).

share|improve this answer
We run our cron jobs with super-user account, but login to a dev account. So from dev account I need to do sudo crontab -e. I set export EDITOR=vim in both super-user's and the dev account's .bashrc, but sudo crontab -e was still opening up in nano. After uninstalling nano, it opens vim. Thanks! – arun Jul 27 '13 at 17:06
This is the only solution that worked for me. Tried 4-5 things before this :) – Charlie Wynn Nov 24 at 1:54
export EDITOR=vi && crontab -e 

works on debian squeeze

share|improve this answer
A little explanation would go a long way. – ChrisF Oct 1 '12 at 21:15
this sets the EDITOR environment variable and subsequently edits the crontab file, EDITOR=vim crontab -e will work as well, but only one time. – 0x4a6f4672 Nov 21 '12 at 16:56

You should best remove the ~/.sensible_editor file and then running crontab -e will prompt you to choose the preferred editor.
From then on your preference will be remembered in the ~/.sensible_editor file.

share|improve this answer
not sure why this was down voted it is exactly what I need and worked perfectly. – rob Oct 28 at 13:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.