Editing Files in Linux Using VI or VIM

shape
shape
shape
shape
shape
shape
shape
shape

In most distributions VI is the default text editor. Although it has good features, it is not at all user-friendly for the lay user.

Execution modes

In VI there are three execution modes:

  1. Navigation mode
  2. Insertion mode
  3. Command mode

Navigation mode

It’s the VI’s initial mode. When we start editing a file, we are dropped into navigation mode. It is from navigation mode that we can then enter Insertion Mode and Command Mode

# vi /etc/apache2/apache.conf

After the above command we are in navigation mode. This mode allows you to execute a series of commands, see the command table below:

[table id=”1″ /]

Insertion mode

To enter insert mode, press the “i” or “a” key. When you enter insert mode, you can insert and delete text in the file.

To end insertion mode and return to navigation mode, press the “ESC” key.

Command mode

To enter control mode, press the ” : ” key.

This command is preceded by another command, thus executing an action according to the table below:

[table id=”2″ /]

Remember that some commands have the same action.

Leave a Reply

Your email address will not be published. Required fields are marked *

Latest news

Latest news directly from our blog.