I am using Ubuntu 18.04. The default text editor now appears to be nano. I want to set it to always be vi. Other posts suggest the following command, however this command does not list the vi I want to use.

$ sudo update-alternatives --config editor
There are 4 choices for the alternative editor (providing /usr/bin/editor).

  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    15        manual mode

I want to use the following:

$ which vi

How do I set the default editor?


3 Answers 3


If you want to make /usr/bin/vi as default editor.. First you need to install it..

To install it run the below command..

sudo update-alternatives --install /usr/bin/editor editor /usr/bin/vi 9999

Then run the below command

sudo update-alternatives --config editor

see the * mark.. and choose the number equals to /usr/bin/vi path

enter image description here


So, VIM is VI-improved. As to why VI is replaced by VIM is answered here: https://superuser.com/questions/852177/why-does-the-vi-command-open-vim-editor

/usr/bin/vi is usually a pointer to vim:

ls  -lah /usr/bin/vi
lrwxrwxrwx 1 root root 20 Jul 25  2018 /usr/bin/vi -> /etc/alternatives/vi
ls -lah /etc/alternatives/vi
lrwxrwxrwx 1 root root 18 Jul 25  2018 /etc/alternatives/vi -> /usr/bin/vim.basic

I use vim.basic for my vi.


If you want to define the default editor just for a session type:

$> export EDITOR=vi

or to persist the setting you can append it to ~/.bashrc (Create the file if it does not exist.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .