Show Menu
Cheatography
This is a draft cheat sheet. It is a work in progress and is not finished yet.

1

Open file
vi filename
Save and quit
ZZ

:wq
Discard edit and return to original file
:e!
Discard edit and quit
:q!

2

Single movement
h left one space
j down one line
k up one line
l right one space
Multiple movement
5h left five space
5j down five line
5k up five line
5l right five space
Line movement
0 move to beginning of line
$ move to end of line
G go to end of file
5G go to line number 5
Text block movement
w move forward by word
W move forward by word not counting punctu­ation
b move backward by word
B move backward by word not counting punctu­ation
+ move to first character of next line
- move to first character of previous line
Text Addition
i insert text before cursor position
I insert text at the beginning of line
A append text at the end of line
a insert text after cursor position
cw change text forward by word
c2b change text backward by two word
c$ change text forward to end of line
C change text foward to end of line
c0 change text backward to beginning of line
cc change entire line
r replace one character
s substitute one character 5s substitute five character
S substitue entire line
R replace text in overstrike mode
~ change case of a letter
dw delete text forward by one word
d2b delete text backward by two word
dd delete entire line
D delete forward from current cursor position
x delete foward by one character
p put text after cursor position
P put text before cursor position
yw copy forward by one word
yy copy entire line
. repeat last command
u undo last command
o open blank line below cursor
O open blank line above cursor
U restore file to original state
Line Addition
J join two lines
 

3

Scroll forward one screen
CTRL + F
Scroll backward one screen
CTRL + B
Scroll forward half screen
CTRL + D
Scroll backward half screen
CTRL + U
Move current line to top of screen and scroll
z + ENTER
Move current line to center of screen and scroll
z + .
Move current line to bottom of screen and scroll
z + -
Redraw the screen
CTRL + L
Move to the top line on screen
H
Move to middle line on screen
M
Move to last line on screen
L
Move to n lines below top line
nH
Move to n lines above last line
nL
Move to first character of next line
ENTER
Move to first character of next line
+
Move to first character of previous line
-
Move to first nonblank character of current line
^
Move to column n of current line
n |

3

Scroll forward one screen
CTRL + F
Scroll backward one screen
CTRL + B
Scroll forward half screen
CTRL + D
Scroll backward half screen
CTRL + U
Move current line to top of screen and scroll
z + ENTER
Move current line to center of screen and scroll
z + .
Move current line to bottom of screen and scroll
z + -
Redraw the screen
CTRL + L
Move to the top line on screen
H
Move to middle line on screen
M
Move to last line on screen
L
Move to n lines below top line
nH
Move to n lines above last line
nL
Move to first character of next line
ENTER
Move to first character of next line
+
Move to first character of previous line
-
Move to first nonblank character of current line
^
Move to column n of current line
n |
Move to end of word
e
Move to end of word (ignore punctu­ation)
E
Move to beginning of current sentence
(
Move to beginning of current sentence
)
Move to beginning of current paragraph
{
Move to beginning of next paragraph
}
Move to beginning of current section
[[
Move to beginning of next section
]]
Search for a pattern forward
/pattern
Search for a pattern backward
?pattern
Repeat search in same direction
n
Repeat search in opposite direction
N
Repeat search forward
/ENTER
Repeat search backward
?ENTER
Find next occurrence of x in the line
fx
Find previous occurrence of x in the line
Fx
Find character before next occurrence of x in the line
tx
Find character after previous occurence of x in the line
Tx
Repeat previous find command in same direction
;
Repeat previous find command in opposite direction
,
Go to line number n of the file
nG
Go to last line of the file
G