Vim Cheatsheet
Quick reference for Vim commands covering modes, movement, editing, search/replace, file operations, window management, visual mode, and macros
93 commands
iEnter insert mode before cursor
iaEnter insert mode after cursor
aIInsert at beginning of line
IAAppend at end of line
AoOpen new line below and insert
oOOpen new line above and insert
OEscReturn to normal mode
EscvEnter visual mode (character)
vVEnter visual mode (line)
VCtrl-vEnter visual block mode
Ctrl-vREnter replace mode
Rh / j / k / lMove left/down/up/right
5jwMove to next word start
3wbMove to previous word start
2beMove to end of word
e0Move to beginning of line
0$Move to end of line
$^Move to first non-blank character
^ggGo to first line of file
ggGGo to last line of file
G:{n}Go to line number n
:42Ctrl-fScroll down one page
Ctrl-fCtrl-bScroll up one page
Ctrl-b%Jump to matching bracket
%f{char}Jump to next char in line
fat{char}Jump to before next char in line
taxDelete character under cursor
xddDelete (cut) entire line
3dddwDelete word
dwd$Delete to end of line
d$d0Delete to beginning of line
d0yyYank (copy) entire line
5yyywYank word
ywpPaste after cursor
pPPaste before cursor
PuUndo last change
uCtrl-rRedo last undo
Ctrl-rr{char}Replace character under cursor
raccChange entire line
cccwChange word
cwCChange to end of line
CJJoin line below to current
J~Toggle case of character
~>>Indent line
>><<Unindent line
<<.Repeat last command
./{pattern}Search forward for pattern
/error?{pattern}Search backward for pattern
?warningnMove to next search match
nNMove to previous search match
N:s/old/new/Replace first match in current line
:s/foo/bar/:s/old/new/gReplace all matches in current line
:s/foo/bar/g:%s/old/new/gReplace all matches in file
:%s/foo/bar/g:%s/old/new/gcReplace all in file with confirmation
:%s/foo/bar/gc*Search forward for word under cursor
*#Search backward for word under cursor
#:nohClear search highlighting
:noh:wSave file
:w:w {file}Save as specified filename
:w newfile.txt:qQuit
:q:q!Force quit without saving
:q!:wqSave and quit
:wq:xSave and quit (if modified)
:xZZSave and quit (same as :x)
ZZ:e {file}Open file for editing
:e ~/.vimrc:r {file}Insert file contents
:r header.txt:set numberShow line numbers
:set number:set pasteEnable paste mode
:set paste:set syntax=onEnable syntax highlighting
:set syntax=on:splitHorizontal split
:split file.txt:vsplitVertical split
:vsplit file.txtCtrl-w wSwitch to next window
Ctrl-w wCtrl-w h/j/k/lMove to window in direction
Ctrl-w lCtrl-w =Equalize window sizes
Ctrl-w =Ctrl-w qClose current window
Ctrl-w q:tabnewOpen new tab
:tabnew file.txtgtGo to next tab
gtgTGo to previous tab
gT:tabcloseClose current tab
:tabclosev + motionSelect characters then operate
vwV + motionSelect lines then operate
V5jd (visual)Delete selection
vwdy (visual)Yank selection
Vjy> (visual)Indent selection
V5j>< (visual)Unindent selection
V5j<gvReselect last visual selection
gvq{reg}Start recording macro to register
qaqStop recording macro
q@{reg}Play back macro from register
@a@@Replay last macro
@@"{reg}yYank to named register
"ayy"{reg}pPaste from named register
"ap:regShow all register contents
:reg