Entering the editing mode in VI
Follow the below steps to enter the editing mode in vi
Step 1: Open a File in Vi
To start editing a file with Vi, open your terminal.
Type the following command: vi filename, replacing “filename” with the name of the file you want to edit. If the file doesn’t exist, Vi will create a new one with the provided name.
vi filename
Replace “filename” with the name of the file you want to edit. If the file does not exist, Vi will create a new one with the provided name.
Step 2: Navigate to Command Mode
When you open a file in Vi, you start in the command mode. In this mode, you can issue commands to navigate, save, and manipulate text. To ensure you are in command mode, press the Esc key. This step is crucial because you cannot enter text in other modes.
Step 3: Enter Insert Mode
To enter insert mode, which allows you to add or modify text, press one of the following keys while in command mode:
Option |
Description |
---|---|
i |
Start inserting text before the current cursor position. |
I |
Start inserting text at the beginning of the current line. |
a |
Start inserting text after the current cursor position. |
A |
Start inserting text at the end of the current line. |
o |
Open a new line below the current line and enter insert mode. |
O |
Open a new line above the current line and enter insert mode. |
Step 4: Editing Your Text
Once you are in insert mode, you can freely type and edit your text. Make the necessary changes, additions, or deletions as required.
Step 5: Return to Command Mode
After you have made your edits, press the Esc key to return to command mode. This step is vital because it allows you to save or exit the file.
Step 6: Save and Exit
To save your changes and exit Vi, use the following command in command mode:
:wq
You will not be able to quit if you do not use “!” .
Step 7: Discard Changes and Exit
If you made changes but wish to discard them and exit Vi, use the following command in command mode:
:q!
how to Enter in Editing Mode in VI Editor
The Vi editor, short for “Visual Editor,” is a powerful and widely used text editor in the Unix and Linux operating systems. Vi offers various modes for text manipulation, including command mode, insert mode, and visual mode. In this article, we will focus on entering the editing mode, which is essential for making changes to your text files in Vi.