Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

I have run the following commands:

sudo update-alternatives --config editor

and

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

5 Answers 5

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

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

share|improve this answer

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

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 at 19:13
    
+1 for "nano_must_die" –  BryceAtNetwork23 Aug 14 at 14:27

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

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.