Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to change the default editor from nano to vim.

I have run the following commands:

sudo update-alternatives --config editor


update-alternatives --config editor

Both now output:

  Selection    Path                Priority   Status
  0            /bin/nano            40        auto mode
  1            /bin/ed             -100       manual mode
  2            /bin/nano            40        manual mode
* 3            /usr/bin/vim.basic   30        manual mode
  4            /usr/bin/vim.tiny    10        manual mode

I have restarted my ssh session and restarted sshd but crontab -e still opens in nano

What else do I need to do?

share|improve this question
I don't think any of these answers actually address the question do they? – geotheory Apr 13 at 23:31
up vote 43 down vote accepted

Try your ssh session followed by

export EDITOR=vim

or possibly

export EDITOR=/usr/bin/vim.basic

The format of setting of the EDITOR variable depends on which shell you are using.

In Ubuntu you can set the EDITOR environment variable on logon by adding the above to the ~/.profile

Your SSH session will read a similar file (if it exists) on the remote host called ~/.ssh/environment. This has to be specifically defined by the ssh daemon config. See man sshd_config and look for PermitUserEnvironment for more details.

share|improve this answer
This works in CentOS too – machineaddict May 11 at 11:35

Just simply run select-editor, this will let you choose any editor you want.

share|improve this answer
Better answer I think than what was picked. Don't have to change my bash profile to set the editor. Verified by logging out and logging back in. – DataHerder Mar 8 at 16:15
Should be the accepted answer. Thanks Mostafa! – user570454 Jul 20 at 14:55

My personal preference...

cd /bin
mv nano nano_must_die
ln -s /usr/bin/vim nano
share|improve this answer
I love it, worked out well enough for me after update-alternatives didnt work. – Cole Busby Jan 28 '14 at 19:13
+1 for "nano_must_die" – Aaron Aug 14 '14 at 14: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.

Perhaps you have the EDITOR enivronment variable set to nano?

share|improve this answer

On my Ubuntu 12.04 computer, "crontab" uses a file called


which contains the name of the selected editor. (That is not what the vi "man" page suggests.) I have edited it directly or used "select-editor", which is a script to do the same thing.

IHMO people should not be changing anything in /etc or /bin to do this. It is a user level thing, not a system wide task.

share|improve this answer

I was having difficulties with select-editor and update-alternatives, my solution was to simply edit the link:

  1. sudo rm /etc/alternatives/editor
  2. sudo ln -s /usr/bin/vim /etc/alternatives/editor

editor now opens Vim

share|improve this answer
sudo apt-get remove nano

Have fun!

share|improve this answer
-1 This removes nano. While it has the desired side-effect, OP may not want to remove nano. Depending on the system configuration this may also leave crontab -e dysfunctional, since the editor set in VISUAL or EDITOR is now unavailable. – David Foerster Dec 8 '15 at 19:14

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.