Take the 2-minute tour ×
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

5 Answers 5

up vote 41 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

or

export EDITOR=vim

should do the trick.

share|improve this answer
1  
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
2  
This was gold! thanks. –  saintali May 16 '13 at 8:50

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
export EDITOR=vi && crontab -e 

works on debian squeeze

share|improve this answer
2  
A little explanation would go a long way. –  ChrisF Oct 1 '12 at 21:15
3  
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

Your Answer

 
discard

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.