VI Command in Linux: VI editor is one of the best text editor for Linux. VI is the basic text editor comes with Linux by default. You can create a new text file, edit text file and save the edited text file. With the help of VI Commands, you can use this VI editor in essential ways. In this tutorials, we provides essential VI commands and its uses list.
The VI editor is one of the most famous text editors in Linux. The reason behind its famous are,
- Comes as a default text editor in all Linux Distros.
- Same interface and working in all distros
- Simple and user-friendly application.
- Supports essential file formats
VI Command Mode:
This mode is the default mode in VI editor. In this mode, you can use the move, edit, cut, copy & paste options in VI editor. You can also use this mode to save the edited text file.
VI Insert Mode:
This mode allows you to type the text entries. Switch from command mode to insert mode by pressing the “I” letter in the keyboard. Commands are case sensitive!. To save the text file, Go to command mode by clicking the “Esc” button on the keyboard.
Launching the VI Editor:
You can create the new text file using the VI editor:
- Click the letter “I” in the keyboard will change into insert mode.
- Enter any text inside the text area.
- Now click the “Esc” button to get into the command mode
- Enter the command “:wq” to save the file and quit the file.
- To launch the file “example.txt”, follow the below command:
VI Commands List Table:
To execute the below commands, you must use the VI command mode. The below VI commands are case sensitive.
|i||Command to Insert mode|
|a||Will enter the text after the cursor|
|A||Will enter the text at the end of the line|
|ESC||Exit insert mode|
|u||Undo the last change|
|U||Undo all the changes in the current line|
|o||Open a new line|
| Delete line|
Delete 2 Consecutive lines.
|D||Delete contents of the line after the cursor|
|C||Delete contents of a line after the cursor and insert new text.|
| Delete word|
Delete 3 words
|cw||Change word in the line|
|x||Delete the character at the cursor of the current line|
|r||Replace a character in the current line|
|R||Overwrite characters on previous characters from cursor onward|
|s||Substitute one character under cursor continue to insert|
|S||Substitute entire line|
|~||Change case of individual character in the line|
|k||Move cursor up in the current line|
|j||Move cursor down in the current line|
|h||Move cursor left in the current line|
|l||Move cursor right in the current line|
|Shift+zz||Command to save the file and quit|
|:w||Command to save the file but keep it open|
|:q||Command to quit without saving|
|:wq||Command to save the file and quit|
That’s it. As we said, VI is the basic text editor in Linux. The above list of VI commands will help you use the VI editor easily. If you have any queries related to this tutorial and then feel free to comment us below.
For more articles, Kindly visit our HomePage