How to Change the Default Text Editor Using Nano on Ubuntu : Linux

How to Change the Default Text Editor Using Nano on Ubuntu? All Linux distributions have a text editor set by default. For example, in Ubuntu, nano is set as the default text editor for use in console mode. In Linux, you can change default editor to one of your choice by changing the $EDITOR environment variable.



For example, to change the default editor from nano to vim, I need to open the .bashrc file and append the following line.



#FILE: .bashrc

...

export EDITOR="vim"



Various command line applications such as crontab, svn and visudo make use of the $EDITOR variable to choose the default text editor.



How to change default text editor in Ubuntu



In Debian based Linux distributions (Ubuntu), you can change the default text editor using a script called update-alternatives. This is how it is done …



Open a terminal and type the following command :



$ sudo update-alternatives --config editor



An alternative to using sudo is to login as root, in which case, you can run the above command without using sudo. Next you will be prompted for your password. After you enter the correct password, you are provided a list of console text editors found on your system. Pick your choice to change the default text editor.



[sudo] password for linuxandfriends: *****

There are 3 alternatives which provide `editor'.

Selection Alternative

-----------------------------------------------

1 /usr/bin/vim.tiny

2 /bin/ed

*+ 3 /bin/nano

Press enter to keep the default[*], or type selection number:



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.

Subscribe to Get Newest Articles By Email!

Follow us!

0 comments:

Post a Comment