Bullium Consulting
Vim Cheat Sheet
bullium.com/vim
1 Navigation
Basic Motion
h j k l
Left, down, up, right
w
Start of next word
W
Next WORD (space-delim)
e
End of word
b
Back to start of word
B
Back to WORD start
Line & File
0
Start of line
^
First non-blank char
$
End of line
gg
First line of file
G
Last line of file
:42
Jump to line 42
42G
Same, line 42
1 Scroll & Jump
Scrolling
Ctrl+d
Down half page
Ctrl+u
Up half page
Ctrl+f
Forward one page
Ctrl+b
Back one page
zz
Center current line
zt
Current line to top
zb
Current line to bottom
Jumping
%
Matching bracket
*
Next match of word under cursor
#
Previous match of word
f{c}
Next {char} on line
F{c}
Previous {char} on line
;
Repeat f/F forward
,
Repeat f/F backward
2 Editing
Insert Mode
i
Insert before cursor
I
Insert at line start
a
Insert after cursor
A
Insert at line end
o
New line below
O
New line above
Esc
Back to normal mode
Deleting
x
Delete char under cursor
X
Delete char before cursor
dd
Cut entire line
dw
Delete to next word
d$
Delete to end of line
d0
Delete to start of line
D
Same as d$
2 Change & Repeat
Copy & Paste
yy
Yank (copy) line
yw
Yank word
y$
Yank to end of line
p
Paste after cursor
P
Paste before cursor
Change & Replace
r{c}
Replace one char
R
Enter replace mode
cw
Change word
cc
Change entire line
C
Change to end of line
s
Substitute character
S
Substitute entire line
Undo / Redo / Repeat
u
Undo last change
Ctrl+r
Redo
.
Repeat last edit
5dd
Delete 5 lines (count prefix)
4 Visual Mode
Selecting
v
Character selection
V
Line selection
Ctrl+v
Block (column) selection
gv
Re-select last selection
Acting on Selection
d
Delete selection
y
Yank selection
>
Indent right
<
Indent left
~
Toggle case
=
Auto-indent
5 Files
Save & Quit
:w
Save
:w file
Save as filename
:q
Quit (fail if unsaved)
:q!
Force quit
:wq
Save and quit
:x
Save+quit if modified
ZZ
Same as :x
ZQ
Same as :q!
File Management
:e file
Open file
:e!
Revert to saved
:r file
Insert file contents
:r !cmd
Insert shell output
:!cmd
Run shell command
6 Buffers & Tabs
Buffers
:ls
List buffers
:bn
Next buffer
:bp
Previous buffer
:bd
Close buffer
:b3
Switch to buffer 3
Tabs
:tabnew
Open new tab
:tabn
Next tab
:tabp
Previous tab
:tabclose
Close tab
gt
Next tab (normal)
gT
Previous tab (normal)
7 Windows & Splits
Creating Splits
:sp
Horizontal split
:vsp
Vertical split
:sp file
H-split + open file
:vsp file
V-split + open file
Navigating Splits
Ctrl+w h
Move to left split
Ctrl+w j
Move down
Ctrl+w k
Move up
Ctrl+w l
Move to right split
Ctrl+w w
Cycle splits
Ctrl+w q
Close split
Ctrl+w =
Equalize sizes
8 Macros & Registers
Macros
qa
Record into register 'a'
q
Stop recording
@a
Play macro 'a'
@@
Replay last macro
10@a
Run macro 'a' 10 times
Registers
:reg
Show all registers
"ay
Yank into register 'a'
"ap
Paste from register 'a'
"+y
Yank to system clipboard
"+p
Paste from system clipboard
9 Text Objects
Inner (contents only)
ciw
Change inner word
ci"
Inside double quotes
ci'
Inside single quotes
ci(
Inside parentheses
ci{
Inside curly braces
ci[
Inside square brackets
cit
Inside HTML/XML tags
Around (include delimiters)
daw
Around word (incl. space)
da"
Around double quotes
da(
Around parentheses
yiw
Yank inner word
vi{
V-select inside braces
vip
V-select inner paragraph
dis
Delete inner sentence
Modes
Esc
Normal, navigate & operate
i / a
Insert, type text
v / V
Visual, select text
Ctrl+v
Visual Block, column edit
:
Command-line, ex commands
R
Replace, overwrite text
Power Combos
gg=G
Auto-indent entire file
ggVG
Select entire file
ci"
Replace inside quotes
5dd
Delete 5 lines
c3w
Change next 3 words
>}
Indent paragraph
g~~
Toggle case of line
:%!sort
Sort entire buffer
Ctrl+a
Increment number under cursor
Ctrl+x
Decrement number under cursor