i
Enter insert mode at current position
I
Enter insert mode at beginning of current line
Esc
Leave insert mode
:w
Write current changes
:q
Quit vi editor
dd
Delete/Cut current line
:#1,#2d
Delete/Cut lines #1 through #2
:#
Jump directly to line #
:y
Copy current line
:p
Paste copied or deleted content after current line
:P
Paste copied or deleted content before current line
o
Insert a blank line below the current position
Shift+o
Insert a blank line above the current position
-
Go to the beginning of the previous line
0 or ^
Go to the beginning of current line
Return or +
Go to the beginning of the next line
$
Go to the end of the current line
Shift+h
Go to the first line on screen
Shift+l
Go to the last line on screen
%
Go to the corresponding opening/closing bracket ((), [], or {})
:n1,n2:s/string1/string2/g
Substitute string2 for string1 on lines n1 to n2. If g is included (meaning global), all instances of string1 on each line are substituted. If g is not included, only the first instance per matching line is substituted.
set number|nonumber
Turn on|off line numbering