How To Change Visudo Default Editor

In this tutorial we learn how to change visudo default editor. I use Ubuntu 20.04 for this tutorial but you should be able to follow this tutorial on any versions and flavors of Ubuntu.

To change visudo default editor, you can use the command below.

sudo update-alternatives --config editor

It will prompt which editor that you want to use. Choose the number of editor that you want to use and press enter

There are 3 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.tiny   15        manual mode

Press <enter> to keep the current choice[*], or type selection number:

Now your default editor for visudo already changed to vim or another editor of your choosing.