Change the Default Editor

Many of the utilities in Ubuntu Linux use a text editor to allow you to edit configuration options and files. An example of this is using the crontab command, which allows you to edit your cron jobs using the default editor.

It’s really easy to set the default editor using the update-alternatives command. Open up a terminal window and type in the following command:

sudo update-alternatives --config editor

Here’s an example of what you’ll see:

$ sudo update-alternatives --config editor
There are 7 choices for the alternative editor (providing /usr/bin/editor).
Selection    Path                    Priority   Status
------------------------------------------------------------
  0            /usr/bin/vim.gnome       60        auto mode
  1            /bin/ed                 -100       manual mode
 * 2            /bin/nano                40        manual mode
 3            /usr/bin/emacs22         0         manual mode
  4            /usr/bin/mcedit-debian   25        manual mode
  5            /usr/bin/vim.basic       30        manual mode
  6            /usr/bin/vim.gnome       60        manual mode
  7            /usr/bin/vim.tiny        10        manual mode

Press enter to keep the current choice[*], or type selection number: 3 
You can select the editor you want by just typing in the number. For example, if I want to change the default editor to vim, I would just hit the number 1.

You can test this out by typing in crontab -e to edit your cron file. You should see the editor that you chose, instead of the default.

Tags: 
X