Changing the Default Text Editor in Linux

A default text editor comes with respective Linux distributions. Such as nano, vim, ed etc. Users can change it according to their preferences by changing the $EDITOR environment variable.

Changing default editor from nano to vim #

You must open the .bashrc file and append the line as shown below.

#FILE: .bashrc

export EDITOR=”vim”

Different command line applications alike the 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 an operating system such as Ubuntu, you need to use a script inorder to change the default text editor known as the update-alternatives. Below is the description of how you can go about doing it.

Open a terminal and enter the below command :

$ sudo update-alternatives –config editor

You may also do this by logging in as root to avoid using sudo to run the command. You then be prompted for password, entering the correct password you would be presented with a list of console text editors found on your system. You may choose between them and change it to using as a default text editor.

[sudo] password for yourserver : *****

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: 1

Furthermore, you may change the default text editor and apply it all across the system (for all users) or choose to change it for a particular user. Following is the procedure for the two :

A. System Wide

Run the following command and choose the one of your choice

$ sudo update-alternatives –config editor

B. User Level

If you are a user with limited privileges or a server admin who only wishes to change the text editor for particular users, you can add an alias for editor to for example vim.

For that purpose, you must Open and edit ~/.bashrc with adding alias editor=vim

You may test it now. Once you open a bash prompt, you’d see the editor has changed according to your preference.

If you need any assistance with this, please contact our support department via. online chat available at our website OR raise a ticket stating your requirements with the preferred text editor.


Like this post ?

Share on your Social Networking Profile ( Facebook, Twitter & Google+ ) and get a flat 10% Recurring discount on our VPS Hosting and Dedicated Servers.

Email us the shared link at : [email protected] or speak to our live chat operator now, by clicking on the “Live Chat” Scroller on the left-hand side of this page and we will provide you with the discount Coupon right away!

Powered by BetterDocs