Basic vi Commands


The following are the common classic commands for the vi text editor that comes with every Linux systems installed and as follows:

 

vi filename 

     open filename in vi

esc 

     returns from insert mode to command mode

:w 

     write the file out

:q 

     quit with no additional writes to the disk

:wq 

     write back the file and then quit

:q! 

     quit the file with impending changes unwritten

/string 

     search forward through the file for string 

?string 

     search backward through the file for

string n 

     find the next string (either forward or backward)

u 

     undo the last command

cw 

     delete the word to the left of the cursor and put the editor in input mode

Shift + I 

     enter insert mode, inserting at the beginning of the current line

Shift + A 

     enter insert mode, inserting at the end of the current line

Shift + ZZ 

     write back the file and then quit