Learn how to use VI editor which is very famous among Embedded Linux and Linux developers. In this article we describe most used commands of VI Editor in brief and crispy manner. Believing that this will be useful to all who want to do Embedded System development based on Linux and even useful to general Linux user.
VI editor is text editor used in Linux OS.
This is very simple and command line based text editor.
If you are interested in VI in Windows OS, then you should try Vim.
Embedded Linux @ EmbeddedCraft YouTube Channel
Why should you learn VI Editor
> VI Editor comes in small package.
> To use this editor, there is no need to have a fancy desktop of Linux.
> Linux at command line is very powerful and VI editor is used at command line.
> In many situation we dont have desktop environment available like the case when linux crashed and you are debugging and at that time only command terminal is available, VI editor is useful
Let us use VI
Create a new file
File creation is simple, just use following commad
ec: $ vi try
Now file will be seen as following
Let us insert text in the file. For this we need to enter into insert mode by pressing colon “:”
Let us press colon key and following will be the look
This is command mode. Now VI will accept commands.
Enter “i” key now to enter into insert mode.
now we can enter the text.“i” key now to enter into insert mode.
Let us save and close. For this again we need to go back to command mode. For this use escape key followed by colon “:”.
After that we can use command for save and close which is “wq”
After that we return to terminal back.
We can use list command to see if file exit.
ec: $ vi try
ec: $ ls
and let us use cat command to see content of file.
ec: $ cat try
This is the first.
We have created by VI editor.
VI works in command and insert mode. User “i” to enter into text mode. Use escape to back to command mode.
Below is the important command
create a new file
save and close the file
close without save
save as file
Hope this article will be useful, For more please refer manual of VI Editor. Just type following command in terminal.
ec: $ man vi