Vim Commands

Mode Switching

iInsert before cursor
IInsert at line start
aAppend after cursor
AAppend at line end
o / ONew line below / above
v / VVisual / line select
Ctrl+vVisual block mode
EscReturn to normal mode
RReplace mode
:Command mode

Movement

h j k lLeft, down, up, right
w / bNext / prev word
eEnd of word
0 / $Start / end of line
^First non-blank char
gg / GTop / bottom of file
:nGo to line n
Ctrl+d / Ctrl+uHalf page down / up
Ctrl+f / Ctrl+bFull page down / up
{ / }Prev / next paragraph
%Matching bracket
H / M / LTop / mid / bottom screen

Editing

xDelete char at cursor
ddDelete (cut) line
dwDelete word
DDelete to end of line
ccChange (replace) line
cwChange word
CChange to end of line
r<char>Replace single char
JJoin line below
~Toggle case
.Repeat last command
u / Ctrl+rUndo / redo

Copy & Paste

yyYank (copy) line
ywYank word
y$Yank to end of line
p / PPaste after / before
ddCut line
"ayYank into register a
"apPaste from register a
:regView all registers

Search & Replace

/patternSearch forward
?patternSearch backward
n / NNext / prev match
*Search word under cursor
:%s/old/new/gReplace all in file
:s/old/new/gReplace in current line
:%s/old/new/gcReplace with confirm
:nohClear search highlight

Files & Buffers

:wSave file
:qQuit
:wq / :x / ZZSave and quit
:q!Quit without saving
:e fileOpen file
:bn / :bpNext / prev buffer
:lsList buffers
:sp / :vspHorizontal / vertical split

Window & Tabs

Ctrl+w sHorizontal split
Ctrl+w vVertical split
Ctrl+w h/j/k/lNavigate splits
Ctrl+w =Equal split sizes
:tabnewNew tab
gt / gTNext / prev tab

Macros & Marks

qaRecord macro to reg a
qStop recording
@aPlay macro a
@@Repeat last macro
maSet mark a
'aJump to mark a
''Jump to last position
:marksList all marks

Text Objects

diwDelete inner word
ciwChange inner word
di"Delete inside quotes
ci(Change inside parens
da{Delete around braces
ditDelete inside tag
yiwYank inner word
vipSelect paragraph
allprintabledoc.com