Skip to main content

Vim Advanced Cheat Sheet


Modes (Quick Recap)​

ModeKey
NormalEsc
Inserti, a, o
Visualv, V, Ctrl+v
Command:

Advanced Navigation​

CommandAction
ggGo to first line
GGo to last line
HTop of screen
MMiddle of screen
LBottom of screen
Ctrl + dHalf page down
Ctrl + uHalf page up
Ctrl + fFull page down
Ctrl + bFull page up
%Jump to matching bracket

Search & Navigation​

CommandAction
/textSearch forward
?textSearch backward
nNext result
NPrevious result
*Search word under cursor
#Reverse search word

Replace (Advanced)​

CommandAction
:%s/a/b/gReplace all
:%s/a/b/gcReplace with confirm
:10,20s/a/b/gReplace in line range
:%s/\<word\>/new/gReplace whole word
:%s/a/b/giIgnore case

Visual Mode Power​

CommandAction
vCharacter select
VLine select
Ctrl+vBlock select
>Indent
<Un-indent
=Auto-indent
yCopy
dDelete

Editing Power Moves​

CommandAction
ciwChange inner word
ci"Change inside quotes
di(Delete inside parentheses
yi{Yank inside {}
xpSwap characters
JJoin lines

Repeat & Undo​

CommandAction
.Repeat last command
uUndo
Ctrl+rRedo

File & Buffer Management​

CommandAction
:e fileOpen file
:wSave
:qQuit
:wqSave & quit
:lsList buffers
:b 2Switch buffer
:bdDelete buffer

Split Windows​

CommandAction
:splitHorizontal split
:vsplitVertical split
Ctrl+w wSwitch window
Ctrl+w qClose window

Macros​

CommandAction
qaStart recording macro a
qStop recording
@aRun macro
@@Repeat last macro

Registers​

CommandAction
"ayYank to register a
"apPaste from register a
"+yCopy to system clipboard
"+pPaste from clipboard

Productivity Tips​

  • . → repeat last command
  • ciw → fastest word edit
  • :%s/foo/bar/gc → safe replace
  • gg=G → auto-indent file
  • :noh → remove search highlight