Default Text Editor in Linux [Check, Set, and Change]

LINUX
FUNDAMENTALS
A Complete Guide for Beginners Enroll Course Now

A default text editor refers to the text editor that is automatically used to open and edit text files when no particular editor is specified. It plays an essential role in various tasks such as writing scripts, editing configuration files, or taking notes. Generally, most Linux distributions come with a default text editor. However, users have the flexibility to change the editor according to their preferences and workflow.

In this article, I’ll discuss some of the most common default text editors as well as how to modify and set them in Linux.

Default Text Editors in Some Linux Distributions

The default text editor in Linux can vary depending on the distribution you are using. Here are the common default text editors for some popular Linux distributions:

Distribution Default Editor
Ubuntu Nano
Debian Nano
CentOS Nano
Arch Linux Nano
Linux Mint Xed (Based on Gedit)
openSUSE Nano
Fedora Vim (Vi Improved)
Kubuntu Kate

How to Check Default Text Editor in Linux?

To check the default text editor in your Linux, open the terminal and run echo $EDITOR command. This command will print the value of the EDITOR environment variable, which typically stores the default text editor. In Debian-based Linux distribution, you can also use  update-alternatives --display editor command to check the default text editor.

Checking default text editor in LinuxThe above image shows that the default text editor is vim.

How to Set the Default Text Editor in Linux?

Setting the default text editor in Linux involves configuring the system so that every time you open a file in Linux, the system will automatically open the text editor of your choice. Here’s how you can set the default text editor in Linux:

1. Using ‘select-editor’ Command

The select-editor command lists all the editors available on the system and prompts users to select one of them. It is an easy-to-use tool in some Linux distributions that lets users interactively set the default text editor.

To set the default text editor, open your terminal and run the following command:

select-editor

It lists all the available text editors in your distribution. Now, choose an option that you want to set as your default text editor and press ENTER.

Setting default text editor using 'select-editor' commandFrom the image, you can see the above command lists the editors with a number that you can use to select your default text editor.

2. Using ‘update-alternatives’ Command

The update-alternatives command using the --config editor option presents a list of available editors installed on the system and prompts users to choose the default editor from the list.

To set the default text editor employ the update-alternatives command in the terminal:

sudo update-alternatives --config editor

Setting default text editor using 'update-alternatives --config editor' command

This image shows a list of installed editors (Nano and Vim) in my system and I can select one of them as my default text editor.

3. Configuring ‘EDITOR’ Environment Variable in ‘.bashrc’ File

To set the default text editor, follow the steps:

  1. Open the ‘.bashrc’ file:
    nano ~/.bashrc
  2. Scroll down, and add the following line at the bottom:
    export EDITOR=/path/to/your_preferred_editor

    Setting default text editor by configuring 'EDITOR' environment variable in '.bashrc' file

  3. Press CTRL+S to save and CTRL+X to exit.
  4. Now, to apply the changes, either restart the terminal session or run the command below:
    source ~/.bashrc

Note: Use the which command to find the path to your preferred text editor. For example, which vim displays the full path where Vim is installed.

4. Configuring ‘VISUAL’ Environment Variable in ‘.bashrc’ File

To configure the default text editor, go through the following steps:

  1. Open the ‘.bashrc’ file using nano ~/.bashrc.
  2. Add the following line at the bottom of the file:
    export VISUAL=/path/to/your_preferred_editor

    Setting default text editor by configuring 'VISUAL' environment variable in '.bashrc' file

  3. Press CTRL+S to save and CTRL+X to exit.
  4. Finally, run the command source ~/.bashrc to set the changes or open a new terminal session.

Note: Among all the methods of configuring the default text editor, environment variables will override the settings for the current user session.

Conclusion

In conclusion, the choice of the default text editor is subjective, depending on the user’s familiarity with the editor, workflow preference, and the type of work that needs to be done. With a wide range of choices available, you can customize your Linux environment to maximize your text editing experience.

People Also Ask

Which text editor is used in Linux?

There are a variety of text editors used in Linux such as Nano, Vim, Sublime Text, Emacs, Gedit, etc, each with its particular features. However, choosing the right text editor depends on individual preferences, workflow needs, and experience with the editor’s functionalities.

How to change the default text editor in Linux?

To change the default text editor in Linux, you can use the select-editor command or sudo update-alternatives --config editor command. Also, you can configure the ‘EDITOR’ or ‘VISUAL’ environment variable in your shell configuration file such as ‘.bashrc’ to specify your preferred text editor. Moreover, you can change the default editor by utilizing the settings of your desktop environment.

How to set default editor as Vim in Linux?

To set the default editor as Vim in Linux, add the line export EDITOR=path/to/vim to any shell configuration file such as ‘.bashrc’. After adding the line, save the file and run source ~/.bashrc to apply the changes.

What is the default text editor for Linux GUI?

The default text editor for Linux GUI can vary depending on the desktop environment. The default text editors for some popular Linux desktop environments are Gedit for GNOME, Kate for KDE Plasma etc.

How do I change my default editor from Vi to nano?

To change your default editor from Vi to nano, add the lines export VISUAL=path/to/nano and export EDITOR=path/to/nano in your ‘.bashrc’ file, save the file and exit. Next, to apply the changes without restarting the shell, run the command source ~/.bashrc. Now, nano is set as the default editor and you can confirm it by running echo $EDITOR in the terminal.

What is the default editor in Ubuntu?

The default editor in Ubuntu is Nano. It is a simple, lightweight, and user-friendly text editor with essential editing features like syntax highlighting, search and replace, etc.

Related Articles


<< Go Back to Linux Text Editors | Learn Linux Basics

Rate this post
Nadiba Rahman

Hello, This is Nadiba Rahman, currently working as a Linux Content Developer Executive at SOFTEKO. I have completed my graduation with a bachelor’s degree in Electronics & Telecommunication Engineering from Rajshahi University of Engineering & Technology (RUET).I am quite passionate about crafting. I really adore exploring and learning new things which always helps me to think transparently. And this curiosity led me to pursue knowledge about Linux. My goal is to portray Linux-based practical problems and share them with you. Read Full Bio

Leave a Comment