Show Menu
Cheatography

VIM Cheat Sheet Cheat Sheet (DRAFT) by

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

Modes

Mode
Key Press
Descri­ption
NORMAL
ESC
Can enter other modes, or use shortcuts
COMMAND
:
Can execute commands
INSERT
i
Insert at current position

Cursor Navigation Shortcuts

Shortcut
Descri­ption
ctrl + e
Scroll Down
ctrl + y
Scroll Up
ctrl + f
Page Down
ctrl + b
Page UP
ctrl + u
Half Page Up
ctrl + d
Half Page Down
gg
Top of File
G
Bottom of File
H
Top of Page
M
Middle of Page
L
Bottom of Page
w
Start of next word
e
End of next word
E
End of next word (ignore punctu­ation)
b
Start of previous word
B
Start of previous word (ignore punctu­ation)
$
Move to end of current line
0 (zero)
Move to start of current line
Prefixing commands with a number will repeat the command the specified number of times. For example: 5w will move the cursor to the 5th word

Command Mode Commands

Commands
Descri­ption
Example
:e file
Edit a file in a new buffer
:e new_fi­le.txt
:r file
Read in the file
:r /tmp/f­ile.txt
:r !{cmd}
Read in the CMD's STDIN
:r !{ls -l}
:1 (Any number)
Go to line number
:15
:/
Search forward for pattern
:/string_to_find
:?
Search backward for pattern
:?stri­ng_­to_find
:s
Substitute on current line
:s/foo­/bar/
:%s
Substitute in document
:%s/fo­o/bar/
 

Text Entry

Shortcut
Descri­ption
a
Append text following cursor
A
Append text to end of current line
i
Insert text before cursor
I
Insert text at start of current line
o
Insert text after a new line below
O
Insert text after a new line above

Text Deletion

Shortcut
Descri­ption
x
Delete character under cursor
dw
Delete word (include whites­pace)
de
Delete to end of word (exclude whites­pace)
db
Delete word backward (includes whites­pace)
d$
Delete to end of line (leaves blank line)
dd
Delete line
d^
Delete to start of line
Prefixing commands with a number will repeat the command the specified number of times. For example: 5dd will delete five line starting at the cursor going down.

Copy/ Pasting

Shortcut
Descri­ption
yy
Yank current line
y$
From cursor Yank to end of line
yw
From cursor tank to end of word
p
Paste below cursor
P
Past above cursor
u
undo last change
U
Restore line
J
Move line below to end of current line
Prefixing commands with a number will repeat the command the specified number of times. For example: 5yy starting at the cursor will copy 5 lines going down.

Save / Close File

Command
Descri­ption
:w
write to original file
:w file
write to new named file
:q
quit (no changes)
:q!
quit (ignore changes)
:wq
Save and Quit