Send Close Add comments: (status displays here)
Got it!  This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
Linux text editors


1. Linux text editors

2. vi and vim
The default editor on CentOS is vi or vim. The starting mode is insert mode. You can type in this mode.

Even if you do not like this editor, you need to know how to get out of it if somehow it is invoked.

Pressing the colon key ":" goes from insert mode to command mode. When this happens, press the Escape key to get back to insert mode. Make your changes. Press Escape to get back to command mode.

Type ":q!" and then press Enter to get out of the vi editor without saving.

Type ":wq" and then press Enter to save the file and exit,.

3. Nano
When working from the command line, I prefer to use the Nano text editor. It is not installed by default.

To install Nano, use the following command from the command line.

The following Linux command(s) to install the Nano command line text editor.
sudo yum -y install nano

Note that the sudo command allows a user special root access to install software, make changes, etc.

Rather than logging in as root, the sudo command allows individual commands to be executed. (Or, multiple commands if running the Bash shell using sudo bash and then, when done, exit).

4. Default editor
The default editor can be set as Nano in two ways. Note that some changes may not take effect until you exit and reenter the system.

5. User default editor
Use the following command to open the file ~/.bash_profile.
nano ~/.bash_profile

Type the following at the end of the file (which might be empty if nothing is there yet).
export VISUAL="nano" export EDITOR="nano"

To save the file, type Ctrl-X and then y (to save) and then Enter.

6. End of page