What is VI Command in Linux?
VI 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.
- Modes of Operations on VI Editor
- Getting Started with VI Editor
- Saving and Closing a File in VI Editor
- VI – Available Arguments
- VI – Version Check
Modes of Operations on VI Editor:
There are three kinds of Modes of Operations on VI editor.
- Command Mode.
- Insert Mode.
- 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.
Open a File in VI Editor:
To open a new file or an existing file VI Editor just follow the below mention steps.
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.
This command will open the existing file in read-only mode.
Navigation within a File:
k : Moves the cursor up j : Moves the cursor down h : Moves the cursor to the left. l : 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. I : The Text will be inserted at the beginning of current line. a : The Text will be inserted after current cursor location. A : 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.
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.
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 – Version Check:
Use the below-mentioned command to check the vi editor version information.
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!!