Text Editors in Linux

In Linux, we can create the file in many ways.

  • Using cat command.
  • Using touch command.
  •  Echo command.
  • Using vi or other editors.

 

1-3 methods of files creation have already been explained in their respective sections. Please click on them to know more about their syntax.

Here, we will describe the 4th approach, i.e, using editors.

 

Editors

“Editor is a tool provided by the operating system to work with files. “

This is similar to our notepad, WordPad, and other tools available for editing files on the machine on windows OS.

 

Different list of Editors

Linux operating system is equipped with wide variety of editors to work with documents. They are,

Vi or view editor

vim

Nano editor

Emacs

Gedit

Others..

Here, we will discuss vi editor options for handling files in Linux.

 

About Vi

Vi stands for “Visual Interface” Editor. It is by default provided with Linux flavor operating systems.

 

Creating the file using vi editor

By using the vi editor, we can create the files and modify the files.

The syntax for creating the file is

vi <file name>

 

let’s understand its process with below example,

we want to create a file with abclearn1 and update few lines in it.

 

Step-1:

On the terminal window type,

[admin@sys1 ~]$ vi abclearn1

 

Note: 

For any text file in Linux, it is not mandatory to give file extensions.

i.e, abclearn1 and abclearn1.txt both are same.

 

Step-2:

The Vi editor creates a new file with abclearn1 but it is not yet saved and doesn’t have any content in it.

Below shown an example of the file.

We can start entering the content into the file.

Some test content
Test content in line 2
~
Entering the content in lines
~
~
~

 

Step-3:

To save this file, we should give

Press Esc button – we can observe that ” --insert--“ option is gone.

Now,

Type, “:w” -- for writing the content permanent to memory.

Then, press enter.

The written content is saved.

 

Step-4:

To come out of this file,

“:q!” -- q is for quitting.

 

Vi editor basic operations:

Assume that I have opened a file using vi editor,

We thought file basic operations can be better explained in the form of questions and answers. So, we have framed the same.

These are few which are regularly used on the day to day operations.

 

 

Topics Summary