EMBEDDED LINUX TUTORIAL
VI Editor A Quick Look
A Practical Approach
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.

http://www.vim.org/


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
vi <file_name>

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

try


and let us use cat command to see content of file.

ec: $ cat try

This is the first.

We have created by VI editor.

ec: $



Conclude

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
vi <file_name>

save and close the file
:wq

close without save
:q!

quit
:q

save as file
:w <new_file_name>

Hope this article will be useful, For more please refer manual of VI Editor. Just type following command in terminal.

ec: $ man vi
EmbeddedCraft : Published Date: 4-April-2021   |   Feedback: For any feedback please write to us at embeddedcraft_at_gmail_dot_com