Vim Cheat Sheet

Built from the examples in examples/Vim_cheat_sheets to give a clean, fast in-app reference.

Back to Vim

Global and Files

:h[elp] keyword Open help for keyword.
:e file Edit or open a file.
:sav[eas] file Save current buffer as another filename.
:w Save.
:wq / :x Save and quit.
:q Quit current file/window.
:q! Quit without saving changes.
:qa Quit all files.
ZZ / ZQ Save+quit / quit without saving.
:ter[minal] Open a terminal window.

Movement

h j k l Move left, down, up, right.
w W Next word start (normal / punctuation-aware).
e E Next word end.
b B Previous word start.
0 ^ $ Line start / first non-blank / line end.
gg G nG Top / bottom / go to line n.
f{char} t{char} Find character on line (to / before).
F{char} T{char} Find backward on line.
; , Repeat last find forward / backward.
% Jump to matching bracket/brace/paren.

Insert and Replace

i I Insert at cursor / at start of line.
a A Append after cursor / at end of line.
o O Open line below / above.
s S C Change character / line / to end-of-line.
r R Replace one character / enter replace mode.
Esc or <C-c> Exit insert mode.

Editing and Clipboard

x Delete character.
dd Delete (cut) line.
yy Yank (copy) line.
p P Paste after / before cursor.
dw d$ D Delete word / to end of line / to end of line.
cc Change entire line.
>> << Indent / de-indent line.
u <C-r> Undo / redo.
. Repeat last change.
"*y "+y Copy to system clipboard (if supported).

Visual Mode

v V <C-v> Visual / line visual / block visual mode.
o Switch to opposite end of selection.
y d c Yank / delete / change selection.
> < Indent / de-indent selected lines.
gv Reselect last visual selection.

Search and Replace

/pattern ?pattern Search forward / backward.
n N Next / previous search result.
* # Search next/prev exact word under cursor.
:%s/foo/bar/g Replace in whole file.
:%s/foo/bar/gc Replace in whole file with confirmation.
:noh Clear highlighted search matches.

Windows and Tabs

:split :vsplit Horizontal or vertical split.
<C-w>h/j/k/l Move between splits.
<C-w>w Cycle through windows.
<C-w>q Close current window.
:tabnew Open new tab.
:tabn :tabp Next / previous tab.
:tabclose Close tab.

Macros, Registers, and Marks

:reg List register contents.
"ayy "ap Yank / paste using register a.
qa ... q Record macro into register a.
@a @@ Play macro a / repeat last macro.
ma Set mark a at current position.
'a `a Jump to mark a (line / exact column).

Operators and Text Objects

d{motion} c{motion} y{motion} Delete, change, or yank using a motion.
diw ciw yiw Inner word operations.
da( ci( yi( Around/inside parentheses.
ci" ci' ci` Change inside quotes.
>ap =ip Indent or reformat paragraph text object.

Starter Habits

vimtutor Run in terminal for guided Vim practice.
K Open man page/help for word under cursor.
:set number Show line numbers.
:set relativenumber Show relative line numbers for motions.
:set paste / :set nopaste Paste mode on/off to avoid auto-indent issues.