1. Insert command:
A specifier insert in the word cursor
A at the end of the line where the cursor is inserted
I match either insert in the word cursor
I Insert at the beginning of the line where the cursor
o Insert a new line under the cursor
O insert a new line on the cursor
2. Positioning commands
: Set Nu Sets line number
: Set Nonu Cancel line number
GG to First line
G to last line
NG to Nth row
: N to Nth row
$ move to end of line
0 move to the beginning of the line
3. Delete command
X Delete the character at cursor location
NX removes the n characters after the cursor is located
DD Delete Row of cursor, NDD delete n rows
DG deletes the line from the cursor to the end of the file
D Delete the cursor at the end of the line
: n1,n2d deletes a specified range of rows
4. Copy and Cut commands
YY copy when moving forward
Nyy Copy the current row following n rows
DD Cut when moving forward
NDD cuts the current row following n rows
P, p pasted under the current cursor row or line
5. Replace and Cancel commands
R replaces the character at which the cursor is located
R replaces the character at the beginning of the cursor and presses ESC to end
U Undo Previous Action
Ctrl+r Redo the previous undo operation
6. Search and search for replacement commands
/string search ignores case when searching for a specified string: Set IC
n searches for the next occurrence of the specified string
:%s/old/new/g full text Replace specified string
: N1,n2s/old/new/g replaces specified string within a certain range
7. Save and Exit commands
: W Save changes
: W new_filename Save as specified file
: Wq Save changes and exit
ZZ shortcut keys, save changes and exit
: q! Do not save changes to exit
: wq! Save changes and exit (file owner and root can be used)
Vi,vim Common editing commands