VI (Text Editor) Command in Linux with the Practical Examples!!

The Default Visual Editor for Linux!!


What is VI Command in Linux?


I Command in Linux:  stands for Visual Editor which is default text editor for the Unix based systems. Using the VI Text Editor you can Edit the Existing file also you can create a new file as well. In this article, we will discuss in detail about the VI Command in Linux.

VI Text Editor will work in any of the Linux distributions. Currently, we are using Linux Kubuntu 19.10 for the demonstration of VI Command in Linux.

Jump To:

Modes of Operations on VI Editor:

There are three kinds of Modes of Operations on VI editor.

  1. Command Mode.
  2. Insert Mode.
  3. Escape Mode.

Command Mode: It is the default mode in VI Editor and this mode allows you to delete, copy and paste a text in the file.  You need to press the Esc  key to enter into the command mode.

Insert  Mode: This mode enables you to insert a text into the file. The VI Editor always starts with the command mode so you are required to type the i to enter into the insert mode.

Escape  Mode: This mode enables you to save and close the files.  Type : then the cursor will move to the end of the line.

Getting Started with VI Editor:

This is the basic syntax of VI Command in Linux.

Usage: vim [arguments] [file ..]   edit specified file(s)
or: vim [arguments] –      read text from stdin
or: vim [arguments] -t tag      edit file where tag is defined

Open a File in VI Editor:

To open a new file or an existing file VI Editor just follow the below mention steps.

vi file_name

This command will create a new file of that file name or else if the file name already exists then it will open the existing file.

Check this too  How to Reload Apache on Linux Ubuntu 18.04 LTS?
Open an Existing File
Open an Existing File
vi -R file_name
viiew file_name

This command will open the existing file in read-only mode.

Navigation within a File:

k : Moves the cursor up 
: Moves the cursor down
h : Moves the cursor to the left.
: Moves the cursor to the right.
CTRL+e : Moves screen up.
CTRL+y : Moves screen down.

Insert and Delete a Text in a File:

i : The Text will be inserted before current cursor location.
: The Text will be inserted at the beginning of current line.
: The Text will be inserted after current cursor location.
: Inserting a text at end of current line.
X : Delete a character at the cursor

Copy and Paste a Text in a File:

yy : Copy the text in a current line.
p  : Paste the copied text after the cursor.
Insert Mode Enabled
Insert Mode Enabled

Saving and Closing a File in VI Editor:

SHIFT+zz - This shortcut will save the file and close it.
:w - Saves the file but keep the file open.
:wq - Quit the file without saving.
:q - Saves and close the file.
Saves a File and Quit
Saves a File and Quit

VI – Available Arguments:

  • Launch the Konsole else use the shortcut cut key CTRL+ALT+T to open the Konsole on your system.
  • Copy the following Help command and execute it.
$ vi --help
VI Help Options
VI Help Options

VI – Version Check:

Use the below-mentioned command to check the vi editor version information.

$ vi --version
VI Version Check
VI Version Check


We hope that in the above article have described the information about VI Command in Linux and also illustrated the working guidelines to work with VI Editor. Don’t forget to mention your queries in the comment section and your valued suggestions are always welcome. Keep learning with us. Thank you for visiting our website Tec Robust!!

Leave a Reply

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


How to Install Audacious for Linux Ubuntu 19.10/18.04 LTS?

Install UFW for Kubuntu

Install the UFW (Stable) on Linux Kubuntu 19.10!!