In this blog, we will understand how the VI Editor works in Linux. There are many ways to edit files in Unix. The VI-editor also has an improved version called "vim" editor which stands for "VI" improved editor.
Syntax
vi <filename>
Example
Step 1:
Let us create a new file with name "alpha.txt".
% vi alpha.txt
This will open vi-editor as shown below:
Step 2:
~
~
~
"aplha.txt" 0L, 0B
Step 3
In order to insert any text, press "i" key. Enter few lines.
Hi, How are you?
I am fine, thank you!
~
~
~
~
~
-- INSERT --
Step 4:
Press "Esc" key in order to leave the "insert" mode.
Step 5:
Let's save the file by pressing "Shift", ":" and "wq" as shown below:
hi how are you
i am fine
~
~
~
~
:wq
This will save our file on the Linux system.
Please note: If you want to quit the vi editor without saving the content then, press ":q!".