How to set "nano" text editor default, instead of "vim" or another publisher

If you are a novice user of Linux, the most handy text editor, is definitely "nano". In this tutorial you will learn how to set up the "nano" text editor default, instead of "vim" or another publisher.

Vim si nano are text editors for Linux. Be it Ubuntu or RedHat, CentOSThese editors are vital when it comes to modify a script, crontab or any other file present on the operating system Linux.

Vim (the more advanced version of "vi") and nano are kind Notepad for Linux, with the difference that they do not have a graphic interface. They are opened directly through the command line and edited with their help in terminal / console or log in on Linux through a customer with support SSH, Like Putty or Terminal (macOS).

For many users, vim it's a bit more complicated, having a set of editing commands which rely on typing more effective than the controls shortcut-ers, as it is at nano. For example, if we want to close an open file with "vi", we must type the command: ":quit!"Or shorter":q!", while at "nano"key combination is enough"Ctrl+X". From this point of view, nano is something closer to Windows and interface macOS.

If you have an operating system installed Linux, which is set to "vi” text editor default, then you will have to follow a few simple steps to set the "nano" text editor default in Linux.

How to set "nano" text editor default, instead of "vim" or another publisher

First, make sure you have the "nano” installed on the system. Log in to the system and in terminal run the command:

sudo yum -y install nano

If you already installed the final message you will receive the latest version is already installed on your system

Package nano-2.3.1-10.el7.x86_64 already installed and latest version

To set nano as the default editor CentOS, you need to add the following line to the file ~/.bashrc of your user:

export VISUAL=nano

This will cause any command that opens an editor to use nano instead of the default editor such as vi or vim.

If you want that nano to be default for all users, you can add this line to the file /etc/bashrc. After adding this line, you must upload the file .bashrc with order:

source ~/.bashrc

or

source /etc/bashrc

to make the order active.

This tutorial in which you learn how to set "nano" text editor default, is especially useful for editing commands that execute without specifying which editor to use for that file. The best example is editing crontab, which is done by ordering: crontab -e. Executing this command will open the file cronjobin the set editor default on the system.

In the scenario where EDITOR vi is set default on the system and you don't want to change it, but the file crontab you want it open with nano, then execute in terminal the following command:

env EDITOR=nano crontab -e

file crontab it will open automatically and can be edited with nano for the current session.

Passionate about technology, I enjoy writing on StealthSettings.com since 2006. I have a rich experience in operating systems: macOS, Windows, and Linux, as well as in programming languages and blogging platforms (WordPress) and for online stores (WooCommerce, Magento, PrestaShop).

How to » Linux » How to set "nano" text editor default, instead of "vim" or another publisher
Leave a Comment