How to change the default Editor from Nano in Ubuntu/Debian

In this guide we are going to explore how to change the default editor in Ubuntu/Debian from nano to any other editor of your choice

Linux configuration are mostly text based. Most Linux utilities use a text editor to allow you to edit configuration options and files. An example of this is utilities like crontab and visudo which will use the default editor defined to allow you to change the configurations.

The update-alternatives command allows you to achieve your goal of setting up your preferred text editor. In your terminal window, paste this command

sudo update-alternatives --config editor

This is the output I saw in my case:

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

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

Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/editor (editor) in manual mode

In the above output, you are given a list of the text editors available in the system with the default one marked with an asterisk (*). The prompt expect a number matching the text editor you want to set. In my case, I entered 2 to set the default editor to vim.basic.

You can test this out by typing in a command that will use the editor like visudo to edit your sudo file. You should see the editor that you chose open, instead of the default.

comments powered by Disqus
Citizix Ltd
Built with Hugo
Theme Stack designed by Jimmy