How to use vi editor in Linux?

How to use vi editor in Linux?


Posted in : Ajax Posted on : February 15, 2017 at 6:47 PM Comments : [ 0 ]

In this tutorial I will teach you the commands to use the vi editor to edit text file in Linux computer.

In this tutorial I will teach you the commands to use the vi editor to edit text file in Linux computer.

Linux is powerful operating system and yet runs as gui less mode as a server operating system. In Linux server operating system, system admin mostly uses the vi editor to edit the text files such source code file, script files and system configuration files.

In the Linux desktop distribution many GUI based tools are available for editing the files, but in the server based linux machine most used editor is the vi editor.

The vi editor is know as visual editor which is very handy tools for editing the text files. It provides commands to create a new file, edit the data and finally save the file data. If you have opened the existing file and edited the data you can easily quit the editor with the command Esc -> :q! command.

The vi editor also provide the commands for searching the data in the text file.

Following commands are used to save the file from the vi editor:

1. Press 'Esc' button to go to the Command mode and ':' appears

2. Type :w to save the file

3. Type :wq to save and quit

4. Type :q! to quit without saving

5. Type :wq! to force write to file even if it does not have write permission

6. Type: x to write and quit and this command is short for :wq

7. Type :qa to quit all

Following the video tutorial which shows you how to create a new file in vi editor, edit the file and save it:

The vi editor mode:

The vi editor works in two modes:

  • Command mode: when you first open the editor it is in the command mode and you can enter any command after pressing the : on the keyboard
     
  • Insert mode: In the insert mode you can edit the file. You can press the i button in the command mode to go the Insert mode. In the insert mode press the Esc button of the keyboard to go to the command mode.
     

Here are the list of other commands of vi editor:

Here in this section we are discussing the  Find Commands of the popular vi editor:

? This command finds a word going backwards

/ This command is used to find aword going forwards

f The f command is used to find a character on the line under the cursor going forward

F This command is used a character on the line under the cursor going backwards

t The t command finds a character on the current line going forward and after find the character it stops one character before it

T This is reverse of the f command and it is used to find a character on the current line going backward and after finding the character it stop one character before it

; repeat last f, F, t, T

So, we learned the basic commands of the vi editor.

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics