Skip to main content

Vim Cheatsheet — 122 Commands with Mnemonics and Real Examples

Vim cheat sheet — 100+ commands covering modes, motions, edits, search, registers, splits, with mnemonics.

  • Runs locally
  • Category Developer & DevOps
  • Best for Formatting, validating, shrinking, or inspecting code-adjacent text.
205 commands
Modes (20)
Esc

Leave any mode and return to normal mode. The home base of vim.

Mnemonic: Escape = "get me out of here".

Examples
Esc
Ctrl+[ (same as Esc, doesn't need pinky)
i

Enter insert mode at the cursor — start typing text.

Mnemonic: i = insert (before cursor).

Examples
i
iHello World
a

Enter insert mode after the cursor (append).

Mnemonic: a = append (after cursor).

Examples
a
a // comment
I

Insert at the first non-blank character of the line.

Mnemonic: Capital I = Insert at line start.

Examples
I
I// 
A

Append at the end of the line.

Mnemonic: Capital A = Append at end.

Examples
A
A;
o

Open a new line below and enter insert mode.

Mnemonic: o = open (line below).

Examples
o
ohello
O

Open a new line above and enter insert mode.

Mnemonic: Capital O = Open line above.

Examples
O
O# header
v

Enter visual mode (character-wise) to select text.

Mnemonic: v = visual.

Examples
v
vw (select to next word)
vap (select around paragraph)
V

Enter visual line mode — select whole lines.

Mnemonic: Capital V = Visual line (whole lines).

Examples
V
Vj (select 2 lines)
V}d (select to paragraph end and delete)
Ctrl+v

Visual block mode — select a rectangular block. Lets you edit columns.

Mnemonic: Ctrl+v = vertical/block visual.

Examples
Ctrl+v
Ctrl+v 3j I// Esc (comment 3 lines with //)
R

Enter replace mode — typing overwrites existing characters.

Mnemonic: R = Replace continuously.

Examples
R
Rfoo (replace 3 chars with foo)
:

Enter command mode — type Ex commands like :w, :q, :s.

Mnemonic: Colon = command line.

Examples
:w
:q
:wq
gi

Re-enter insert mode at the last place you left insert mode.

Mnemonic: g + i = "go back to where I was inserting".

Examples
gi
gv

Reselect the last visual selection (same range, same mode).

Mnemonic: g + v = "give me that visual selection back".

Examples
gv
gvd (reselect then delete)
o (in visual)

In visual mode, jump the cursor to the other end of the selection so you can extend it from there.

Mnemonic: o = other end of the selection.

Examples
vjjo (then extend upward)
Ctrl+o (insert)

From insert mode, run one normal-mode command then drop back into insert.

Mnemonic: Ctrl+o = "one normal command, then back".

Examples
Ctrl+o $ (jump to line end without leaving insert)
Ctrl+o dd
Ctrl+w (insert)

Delete the word before the cursor while in insert mode.

Mnemonic: Ctrl+w = wipe a word (insert mode).

Examples
Ctrl+w
Ctrl+u (insert)

Delete everything you typed on this line since entering insert mode (back to insert start).

Mnemonic: Ctrl+u = undo this line of typing (insert mode).

Examples
Ctrl+u
Ctrl+r (insert)

Insert the contents of a register while in insert mode (Ctrl+r then the register letter).

Mnemonic: Ctrl+r in insert = read a register into the text.

Examples
Ctrl+r "  (paste the unnamed register)
Ctrl+r 0 (paste last yank)
Ctrl+r +  (paste system clipboard)
gJ

Join the next line onto this one WITHOUT inserting a space (raw join).

Mnemonic: g + J = Join with no glue (no space).

Examples
gJ
3gJ
Motions (40)
h / j / k / l

Move left / down / up / right by one character. The classic vim arrow keys.

Mnemonic: h is leftmost on home row, l is rightmost. j hangs down like a hook, k kicks up.

Examples
h
5j (down 5 lines)
10l (right 10 chars)
w

Jump to the start of the next word (whitespace-separated tokens count).

Mnemonic: w = word (forward).

Examples
w
3w (forward 3 words)
W

Jump to next WORD — like w but only whitespace separates WORDs (foo.bar is one WORD).

Mnemonic: Capital W = bigger Word (skips punctuation).

Examples
W
dW (delete a WORD including dots)
b

Jump back to the start of the previous word.

Mnemonic: b = back (one word).

Examples
b
3b
e

Jump to the end of the current/next word.

Mnemonic: e = end of word.

Examples
e
de (delete to word end)
ge

Jump backwards to the end of the previous word.

Mnemonic: g + e = "go end backwards".

Examples
ge
0

Jump to the very first column of the line (column 0).

Mnemonic: Zero = column zero, the absolute start.

Examples
0
^

Jump to the first non-blank character of the line.

Mnemonic: ^ points up to "the start of real content".

Examples
^
d^ (delete from cursor back to first non-blank)
$

Jump to the end of the line.

Mnemonic: $ = end of line in regex too. Same idea.

Examples
$
d$ (delete to end of line, same as D)
gg

Jump to the first line of the file.

Mnemonic: gg = go to top.

Examples
gg
5gg (go to line 5)
G

Jump to the last line of the file (or to line N with NG).

Mnemonic: Capital G = Go to bottom.

Examples
G
120G (go to line 120)
:<N>

Jump to line N (e.g. :42 jumps to line 42).

Mnemonic: Colon + number = "go to that line in the file".

Examples
:42
:1
{ / }

Jump to previous / next blank-line-separated paragraph.

Mnemonic: Curly braces wrap a paragraph; the same key wraps your cursor to its boundary.

Examples
{
}
d} (delete to end of paragraph)
( / )

Jump to previous / next sentence (.!? boundary).

Mnemonic: Parens are sentence-shaped — small step.

Examples
(
)
Ctrl+u

Scroll up half a screen, cursor moves with it.

Mnemonic: u = up (half page).

Examples
Ctrl+u
Ctrl+d

Scroll down half a screen, cursor moves with it.

Mnemonic: d = down (half page).

Examples
Ctrl+d
Ctrl+f

Page forward (down a full screen).

Mnemonic: f = forward a full page.

Examples
Ctrl+f
Ctrl+b

Page backward (up a full screen).

Mnemonic: b = back a full page.

Examples
Ctrl+b
zz / zt / zb

Recenter screen so cursor line is in the middle / top / bottom of the viewport.

Mnemonic: z = zoom/position, z+z centers (twins).

Examples
zz
zt
zb
H / M / L

Move cursor to High (top) / Middle / Low (bottom) of the visible screen.

Mnemonic: H = High, M = Middle, L = Low — first letter of each position.

Examples
H
M
L
f<char> / F<char>

Jump forward / backward to the next occurrence of <char> on this line.

Mnemonic: f = find (capital = backward).

Examples
f(
F"
df; (delete up to and including ;)
t<char> / T<char>

Jump till just before / after <char> on this line (exclusive of the char).

Mnemonic: t = till (stop just before the target).

Examples
t)
dt; (delete up to but not including ;)
; / ,

Repeat the last f/F/t/T motion forward / backward.

Mnemonic: ; goes again, , goes opposite (think comma = backward).

Examples
;
,
%

Jump to the matching bracket — ( ), [ ], { }, even matching #if / #endif.

Mnemonic: % looks like two halves meeting — jump between matched pair.

Examples
%
d% (delete from cursor through matching bracket)
Ctrl+o / Ctrl+i

Jump back / forward through the jump list (like browser back/forward).

Mnemonic: o = older position, i = incoming (newer).

Examples
Ctrl+o
Ctrl+i
+ / -

Move to the first non-blank character of the next / previous line.

Mnemonic: + goes down a line, - goes up — landing on real content.

Examples
+
-
3+ (down 3 lines to first non-blank)
|

Jump to a specific column on the current line (N| goes to column N).

Mnemonic: The bar | is vertical — it picks a column.

Examples
1| (column 1)
40| (column 40)
g_

Jump to the LAST non-blank character of the line (unlike $ which lands on the last char even if blank).

Mnemonic: g + _ = "go to last real character".

Examples
g_
dg_ (delete to last non-blank)
gj / gk

Move down / up by a DISPLAY line (useful when a long line is wrapped onto several screen rows).

Mnemonic: g + j/k = move by visual rows, not logical lines.

Examples
gj
gk
nnoremap j gj (make j respect wrapping)
gd / gD

Jump to the local (gd) / global (gD) definition of the identifier under the cursor (keyword search, no index needed).

Mnemonic: g + d = go to definition (lowercase local, uppercase global).

Examples
gd
gD
]] / [[

Jump to the next / previous section or top-level { in column 1 (forward / backward).

Mnemonic: Doubled brackets = jump between big code sections.

Examples
]]
[[
[{ / ]}

Jump to the unmatched { before the cursor / } after the cursor — escape outward from inside a block.

Mnemonic: [{ goes to the opening brace that contains you, ]} to the closing one.

Examples
[{
]}
[( / ])

Jump to the unmatched ( before the cursor / ) after it — same idea as [{ ]} but for parentheses.

Mnemonic: Bracket + paren = jump to the enclosing parenthesis.

Examples
[(
])
Ctrl+e / Ctrl+y

Scroll the window down / up by one line WITHOUT moving the cursor (until it would leave the screen).

Mnemonic: Ctrl+e nudges the view down, Ctrl+y pulls it up.

Examples
Ctrl+e
Ctrl+y
3 Ctrl+e
g; / g,

Jump to older / newer position in the change list (where you last edited).

Mnemonic: g; goes back through edits, g, goes forward.

Examples
g;
g,
`.

Jump to the exact position of the last change in the file (the . mark).

Mnemonic: Backtick + . = "where did I just change something".

Examples
`.
'. (same but line-wise)
`^

Jump to where the cursor was the last time insert mode was stopped.

Mnemonic: `^ = the insert-stopped mark.

Examples
`^
iw / aw

Word text objects: iw = inner word (no surrounding space), aw = a word (includes one adjacent space). Use after an operator.

Mnemonic: i = inner, a = around (a swallows a space too).

Examples
diw
daw
viw (select inner word)
ciw
ip / ap

Paragraph text objects: ip = inner paragraph, ap = a paragraph (includes the trailing blank line).

Mnemonic: ip = inner paragraph, ap = around paragraph.

Examples
dap
vip
yap
it / at

Tag text objects (HTML/XML): it = inside the tag pair, at = the whole tag including <…> and </…>.

Mnemonic: it = inner tag, at = around tag.

Examples
dit
cit
dat
vat
Edit (36)
x

Delete the character under the cursor.

Mnemonic: x = X-out one char.

Examples
x
5x (delete 5 chars)
X

Delete the character before the cursor (backspace in normal mode).

Mnemonic: Capital X = X-out backwards.

Examples
X
r<char>

Replace the character under the cursor with <char>, no mode change.

Mnemonic: r = replace one (single shot).

Examples
ra
r) (turn a } into ))
s

Substitute character — delete the char under cursor and enter insert mode.

Mnemonic: s = substitute (delete + insert).

Examples
s
3sfoo (replace 3 chars with foo)
S

Substitute the whole line — delete it and enter insert mode at the indent level.

Mnemonic: Capital S = Substitute line (cc shortcut).

Examples
S
d<motion>

Delete from cursor to wherever the motion goes (and yank into default register).

Mnemonic: d + motion = delete-that-motion.

Examples
dw (delete to next word)
d$ (delete to end of line)
d5j (delete current + 5 lines below)
dd

Delete the whole current line.

Mnemonic: dd = double-d = delete line (motion is the line itself).

Examples
dd
3dd (delete 3 lines)
D

Delete from cursor to end of line (same as d$).

Mnemonic: Capital D = "Delete the rest".

Examples
D
c<motion>

Change — delete the motion range and enter insert mode in one step.

Mnemonic: c = change (delete + insert).

Examples
cw (change a word)
c$ (change to end of line, = C)
ci" (change inside quotes)
cc

Change the whole line — delete it and enter insert mode at indent.

Mnemonic: cc = double-c = change line.

Examples
cc
C

Change from cursor to end of line (same as c$).

Mnemonic: Capital C = "Change the rest".

Examples
C
y<motion>

Yank (copy) the motion range into the default register.

Mnemonic: y = yank = pull text into register.

Examples
yw (yank a word)
y$ (yank to end of line)
yi( (yank inside parens)
yy

Yank the whole current line.

Mnemonic: yy = double-y = yank line.

Examples
yy
5yy (yank 5 lines)
p

Paste after the cursor / below the current line if yanked content was line-wise.

Mnemonic: p = paste (after).

Examples
p
3p (paste 3 times)
P

Paste before the cursor / above the current line.

Mnemonic: Capital P = Paste before.

Examples
P
u

Undo the last change.

Mnemonic: u = undo.

Examples
u
5u (undo 5 changes)
Ctrl+r

Redo — the inverse of u.

Mnemonic: Ctrl+r = redo (r = redo).

Examples
Ctrl+r
.

Repeat the last change. The most underrated key in vim.

Mnemonic: Period = "do it again".

Examples
.
cw foo Esc j . (change next word to foo too)
>> / <<

Indent / outdent current line by one shiftwidth.

Mnemonic: >> pushes right, << pushes left.

Examples
>>
3>> (indent 3 lines)
V}> (indent paragraph)
~

Toggle case of the character under the cursor (advances cursor).

Mnemonic: Tilde looks wavy — wave between upper/lower.

Examples
~
5~ (toggle 5 chars)
guu / gUU

Lowercase / uppercase the entire current line.

Mnemonic: g + u = go lowercase; g + U = go UPPERCASE.

Examples
guu
gUU
gUw (uppercase one word)
J

Join the next line onto the current one with a space in between.

Mnemonic: Capital J = Join (push lines together).

Examples
J
3J (join 3 lines)
di<obj> / da<obj>

Delete inside / around a text object (word, quotes, parens, tag, etc.).

Mnemonic: i = inner, a = around (a = includes the delimiters).

Examples
diw (delete inside word)
di"
da(
dit (delete inside tag)
ci<obj> / ca<obj>

Change inside / around a text object — like di/da but enters insert mode.

Mnemonic: c + text object = swap that thing.

Examples
ciw (change a word)
ci"
ci{ (change inside braces)
xp

Swap the current character with the next one (delete char, then paste it after).

Mnemonic: x deletes a char, p pastes it one spot later = swap.

Examples
xp (turn "teh" into "the" with cursor on e)
ddp

Swap the current line with the one below it (delete line, paste below).

Mnemonic: dd cuts the line, p drops it back below = move line down.

Examples
ddp
ddkP (move line up)
Ctrl+a / Ctrl+x

Increment / decrement the number at or after the cursor on this line.

Mnemonic: Ctrl+a = add, Ctrl+x = subtract.

Examples
Ctrl+a
10 Ctrl+a (add 10)
Ctrl+x
g Ctrl+a

In a visual block of numbers, create an incrementing sequence (1, 2, 3 …) across the selected lines.

Mnemonic: g + Ctrl+a over a selection = staircase of increments.

Examples
Ctrl+v 4j g Ctrl+a (number 5 lines 1..5)
gp / gP

Paste like p / P but leave the cursor just AFTER the pasted text (handy for chained pastes).

Mnemonic: g + p = paste and go past it.

Examples
gp
gP
]p

Paste and re-indent the pasted lines to match the current line (great for moving code between indent levels).

Mnemonic: ]p = paste, adjusted to local indent.

Examples
]p
[p (paste above with indent fix)
o<Esc>

Open a blank line below and immediately leave insert — a quick way to add an empty line.

Mnemonic: o opens a line, Esc bails out — leaves it empty.

Examples
o<Esc>
O<Esc> (blank line above)
cis / cas

Change inner / a sentence — swap out the sentence the cursor is in.

Mnemonic: c + i/a + s = change sentence.

Examples
cis
das (delete a sentence)
yi( / ya{

Yank inside parentheses / around braces — copy the contents of a bracketed block.

Mnemonic: y + i/a + bracket = yank that bracketed thing.

Examples
yi(
ya{
yi[ (yank inside square brackets)
g~<motion>

Toggle case over a motion range (g~~ toggles the whole line).

Mnemonic: g + ~ = go toggle case over a range.

Examples
g~w (toggle a word)
g~~
g~$
=<motion>

Auto-indent the motion range using the current indent rules (== for the current line).

Mnemonic: = means "make the indentation right".

Examples
==
=ap (reindent a paragraph)
gg=G (reindent whole file)
Ctrl+v $ A

Block-select to end of each line, then A appends the same text to every selected line at once.

Mnemonic: Block + $ + A = append to many line ends together.

Examples
Ctrl+v 3j $ A; Esc (add ; to 4 line ends)
Search & substitute (18)
/<pattern>

Search forward for a regex pattern, hit Enter to jump to the first match.

Mnemonic: Slash = look ahead.

Examples
/foo
/^import.*react
/foo\c (case-insensitive for this search)
?<pattern>

Search backward for a regex pattern.

Mnemonic: Question mark = "looking back to ask".

Examples
?TODO
?function
n / N

Jump to the next / previous search match (in original direction / opposite).

Mnemonic: n = next (same dir), N = opposite.

Examples
n
N
* / #

Search for the word under cursor — forward (*) or backward (#). Whole-word match.

Mnemonic: * draws attention forward to "this word"; # is the mirror.

Examples
*
#
g* (substring match, not whole word)
:noh

Clear the highlighted search results (hlsearch).

Mnemonic: noh = no highlight.

Examples
:noh
:nohlsearch
:s/old/new/

Substitute first match of "old" with "new" on the current line.

Mnemonic: :s = substitute.

Examples
:s/foo/bar/
:s/foo/bar/g (all on this line)
:s/old/new/g

Substitute every match of "old" with "new" on the current line.

Mnemonic: g flag = global within this line.

Examples
:s/foo/bar/g
:%s/old/new/g

Substitute every match in the WHOLE file. The workhorse find-and-replace.

Mnemonic: % = entire file, g = every occurrence on each line.

Examples
:%s/foo/bar/g
:%s/\<foo\>/bar/g (whole word only)
:%s/old/new/gc

Like %s/g but with "confirm" — prompts y/n/a/q/l for each match.

Mnemonic: c flag = confirm each one.

Examples
:%s/foo/bar/gc
:<range>s/old/new/g

Substitute only inside a line range (e.g. 5,20 or visual selection '<,'>).

Mnemonic: Range before s narrows the scope.

Examples
:5,20s/foo/bar/g
:'<,'>s/foo/bar/g (visual selection)
gn

Select the next match of the last search pattern as a visual selection (operator-friendly: cgn changes it).

Mnemonic: gn = go to next match AND grab it.

Examples
cgn (change next match, then . to repeat)
dgn
:g/pat/d

Global command: delete every line matching the pattern. The classic "remove all lines containing X".

Mnemonic: :g = run a command on every matching line; here d = delete.

Examples
:g/TODO/d
:g/^\s*$/d (delete blank lines)
:v/pat/d

Inverse global: delete every line that does NOT match the pattern (keep only matches).

Mnemonic: :v = :g! = act on lines that do NOT match.

Examples
:v/keep/d
:g!/error/d
:g/pat/normal @a

Run a macro (or any normal command) on every line matching a pattern.

Mnemonic: :g + normal = batch a normal-mode command over matching lines.

Examples
:g/^func/normal @a
:g/foo/normal A;
:%s//new/g

Reuse the LAST search pattern in a substitute by leaving the pattern empty.

Mnemonic: Empty pattern in :s = "use my last /search".

Examples
/foo  then  :%s//bar/g
:s/.../\=expr/

Use \= to evaluate a vim expression as the replacement (e.g. arithmetic on the match).

Mnemonic: \= turns the replacement into "compute this".

Examples
:s/\d\+/\=submatch(0)+1/ (add 1 to the number)
\v (very magic)

Put \v at the start of a pattern so most characters are special — regex looks closer to PCRE (fewer backslashes).

Mnemonic: \v = very magic = "treat it like a real regex".

Examples
/\v(foo|bar)
:%s/\v(\w+)\s+\1/\1/g (collapse doubled words)
:sort / :sort u

Sort the lines in range (or whole file). Add u to remove duplicate lines, n for numeric, ! to reverse.

Mnemonic: sort = sort lines; u = unique, n = numeric, ! = reverse.

Examples
:sort
:sort u
:sort n
:%sort! (reverse sort all)
Registers (13)
"a y<motion>

Yank into named register "a" instead of the default register.

Mnemonic: Quote + letter = "use this register slot".

Examples
"ayy (yank line to register a)
"byw (yank word to register b)
"a p

Paste from named register "a".

Mnemonic: Quote + letter + p = paste that register.

Examples
"ap
"bP (paste register b before cursor)
"+y / "+p

Yank to / paste from the system clipboard register (needs +clipboard build).

Mnemonic: + register = system clipboard.

Examples
"+yy (copy line to system clipboard)
"+p (paste from OS clipboard)
"* y / "* p

Yank/paste using the X11 PRIMARY selection (Linux middle-click).

Mnemonic: * register = PRIMARY (the selection one).

Examples
"*yy
"*p
"_ d<motion>

Delete into the black-hole register — does NOT overwrite your clipboard / default.

Mnemonic: Underscore = "throw it away", black hole.

Examples
"_dd (delete line WITHOUT yanking)
"_x
:reg

Show all registers and their current contents.

Mnemonic: reg = registers list.

Examples
:reg
:reg a b "
"0 p

Paste the last yank (register 0 is the yank-only register, unaffected by deletes).

Mnemonic: 0 = the yank-only slot, "rescue clipboard from deletes".

Examples
"0p
"A y<motion>

Yank and APPEND to register a (uppercase register = append instead of overwrite). Great for collecting lines.

Mnemonic: Uppercase register letter = append to that register.

Examples
"Ayy (append this line to register a)
"Add
". p

Paste from the "." register — the text you most recently typed in insert mode.

Mnemonic: . register = "the last thing I typed".

Examples
".p
"% p

Paste the "%" register — the current file name (relative path).

Mnemonic: % register = current file name (like % in :commands).

Examples
"%p
:put % (put filename on a new line)
": p

Paste the ":" register — the last Ex command you ran. Handy for re-editing a command.

Mnemonic: : register = the last : command.

Examples
":p
@: (re-run the last Ex command)
Ctrl+r Ctrl+w (cmdline)

On the command line or search prompt, pull in the word under the cursor (Ctrl+r Ctrl+a pulls the WORD).

Mnemonic: Ctrl+r Ctrl+w = read the cursor word into the command line.

Examples
:s/<Ctrl+r Ctrl+w>/new/
/<Ctrl+r Ctrl+w>
:put <reg>

Put the contents of a register on the line below the cursor (always line-wise, even for char-wise registers).

Mnemonic: :put = drop a register on its own line.

Examples
:put a
:put + (paste clipboard line-wise)
:0put a (put at top of file)
Marks (10)
m<letter>

Set a mark at the cursor with the given letter (a-z local, A-Z global across files).

Mnemonic: m = mark.

Examples
ma (mark a)
mZ (global mark Z)
'<letter>

Jump to the LINE of mark <letter> (cursor lands at first non-blank).

Mnemonic: Single quote = "jump line".

Examples
'a
'A (jump to mark A across files)
`<letter>

Jump to the exact LINE AND COLUMN of mark <letter>.

Mnemonic: Backtick = "jump exact".

Examples
`a
`A
:marks

List all marks currently set.

Mnemonic: marks = list of marks.

Examples
:marks
:marks abc (just a, b, c)
''

Jump back to the position before the last jump.

Mnemonic: '' = bounce back where you were.

Examples
''
:delmarks

Delete marks. :delmarks a deletes mark a; :delmarks! clears all a-z local marks.

Mnemonic: delmarks = delete marks.

Examples
:delmarks a
:delmarks!
'< / '>

Marks set automatically at the start / end of the last visual selection.

Mnemonic: '< and '> are the visual selection boundaries (used in :'<,'>).

Examples
'<
'>
:'<,'>s/foo/bar/g
'[ / ']

Marks at the first / last line (or position with backtick) of the most recently changed or yanked text.

Mnemonic: '[ '] bracket the last change/yank region.

Examples
'[
']
`[v`] (reselect last pasted text)
``

Jump to the exact position before the latest jump (column-precise version of the '' line jump).

Mnemonic: Two backticks = bounce back to the exact spot.

Examples
``
'"

Jump to the position where the cursor was when you last closed this file (restored from viminfo/shada).

Mnemonic: '" = "take me back to where I left this file".

Examples
'"
au BufReadPost * normal! `" (auto-restore on open)
Splits (15)
:sp [file]

Split window horizontally (top/bottom). Open file if given.

Mnemonic: sp = split horizontally (think rows stacked).

Examples
:sp
:sp src/main.ts
:vsp [file]

Split window vertically (left/right). Open file if given.

Mnemonic: vsp = vertical split.

Examples
:vsp
:vsp README.md
Ctrl+w h/j/k/l

Move focus to the window on the left / below / above / right.

Mnemonic: Ctrl+w = window prefix, then hjkl direction.

Examples
Ctrl+w h
Ctrl+w l
Ctrl+w w

Cycle focus to the next window.

Mnemonic: Ctrl+w w = window-window = next.

Examples
Ctrl+w w
Ctrl+w =

Make all windows equal size.

Mnemonic: = sign = make equal.

Examples
Ctrl+w =
Ctrl+w + / Ctrl+w -

Grow / shrink current window height by one row.

Mnemonic: + grows, - shrinks. Same as everywhere.

Examples
Ctrl+w +
5 Ctrl+w + (grow by 5 rows)
Ctrl+w > / Ctrl+w <

Grow / shrink current window width.

Mnemonic: > shifts right edge out, < shifts in.

Examples
Ctrl+w >
10 Ctrl+w >
Ctrl+w o

Make the current window the only one — close all others.

Mnemonic: o = only.

Examples
Ctrl+w o
:only
Ctrl+w q / :q

Close the current window.

Mnemonic: q = quit this window.

Examples
Ctrl+w q
:q
Ctrl+w s / Ctrl+w v

Split the current window horizontally (s) / vertically (v) — same as :sp / :vsp via the window prefix.

Mnemonic: Ctrl+w then s = split, v = vertical split.

Examples
Ctrl+w s
Ctrl+w v
Ctrl+w H/J/K/L

Move the current window to the far left / bottom / top / right of the layout (rearranges splits).

Mnemonic: Capital HJKL with Ctrl+w = shove the whole window that direction.

Examples
Ctrl+w H (move window to far left)
Ctrl+w L
Ctrl+w r

Rotate the windows in the current row/column (swap their positions).

Mnemonic: Ctrl+w r = rotate windows.

Examples
Ctrl+w r
Ctrl+w R (rotate the other way)
Ctrl+w T

Move the current window into its own new tab.

Mnemonic: Ctrl+w T = send this window to a Tab.

Examples
Ctrl+w T
Ctrl+w _ / Ctrl+w |

Maximize the current window height (_) or width (|).

Mnemonic: _ is a flat bar = max height; | is a tall bar = max width.

Examples
Ctrl+w _
Ctrl+w |
Ctrl+w p

Jump to the previously focused window (toggle between two windows).

Mnemonic: Ctrl+w p = previous window.

Examples
Ctrl+w p
Buffers & tabs (14)
:ls / :buffers

List all open buffers with their numbers.

Mnemonic: ls = list (like shell).

Examples
:ls
:buffers
:b <num|name>

Switch to buffer by number or by (partial) filename.

Mnemonic: b = buffer.

Examples
:b 3
:b main.ts
:b#  (go to alternate buffer)
:bn / :bp

Go to the next / previous buffer.

Mnemonic: bn = buffer next, bp = buffer previous.

Examples
:bn
:bp
:bd <num|name>

Delete (close) a buffer.

Mnemonic: bd = buffer delete.

Examples
:bd
:bd 3
:bd main.ts
:tabnew [file]

Open a new tab (optionally with a file).

Mnemonic: tabnew = new tab.

Examples
:tabnew
:tabnew src/index.ts
:tabn / :tabp

Go to the next / previous tab. gt / gT also work in normal mode.

Mnemonic: tabn = tab next, gt = go tab.

Examples
:tabn
:tabp
gt
gT
:tabclose

Close the current tab.

Mnemonic: tabclose = close tab.

Examples
:tabclose
:tabc
:e <file>

Edit (open) a file in the current window.

Mnemonic: e = edit.

Examples
:e ~/.vimrc
:e %:h/<Tab> (browse same directory)
Ctrl+^

Switch to the alternate buffer — the file you were in just before this one. Toggles between two files fast.

Mnemonic: Ctrl+^ = bounce to the other file (the # buffer).

Examples
Ctrl+^
:b#
:bufdo <cmd>

Run an Ex command in every open buffer (e.g. a substitution across all files).

Mnemonic: bufdo = do this in every buffer.

Examples
:bufdo %s/foo/bar/ge | update
:bufdo set ff=unix
:windo <cmd>

Run an Ex command in every window on the current tab.

Mnemonic: windo = do this in every window.

Examples
:windo set scrollbind
:windo diffthis
:tabdo <cmd>

Run an Ex command in every tab page.

Mnemonic: tabdo = do this in every tab.

Examples
:tabdo windo set nu
:bufdo bd / :%bd

Close all buffers at once. :%bd then Ctrl+^ Ctrl+w o is a common "close everything but this file" combo.

Mnemonic: %bd = delete every buffer (the % range covers them all).

Examples
:%bd
:%bd | e# (keep current, close rest)
:sb <num|name>

Open a buffer in a new split instead of replacing the current window.

Mnemonic: sb = split + buffer.

Examples
:sb 3
:vert sb main.ts (vertical split buffer)
Macros (8)
q<letter>

Start recording a macro into register <letter>. Press q again to stop.

Mnemonic: q = quick record.

Examples
qa  (start recording into a)
qa...q (record and stop)
@<letter>

Play back the macro stored in register <letter>.

Mnemonic: @ = at-sign = "execute this register".

Examples
@a
100@a (repeat macro a 100 times)
@@

Replay the last executed macro (no need to remember the letter).

Mnemonic: @@ = "do that again".

Examples
@@
50@@
:let @a = "..."

Set a macro/register manually without recording. Handy for editing macros.

Mnemonic: let @a = "..." writes directly to register a.

Examples
:let @a = "ihello\<Esc>"
qA (append to macro)

Record into an UPPERCASE register to append to an existing macro instead of overwriting it.

Mnemonic: Uppercase q-register = keep recording onto the end.

Examples
qA (append to macro a)
qA...q
Q (replay last @)

In recent vim/neovim, Q replays the last used register macro (like @@). The old Ex-mode meaning was remapped.

Mnemonic: Q = repeat the last macro (newer default).

Examples
Q
:normal @a (over range)

Apply a macro to a range of lines in one shot (no need to count repeats).

Mnemonic: :<range>normal @a = run macro a on each line in the range.

Examples
:5,20normal @a
:'<,'>normal @a
:let @A .= "..."

Append to a register from the command line (.= concatenates) — useful for tweaking a recorded macro.

Mnemonic: .= appends; @A is the append form of register a.

Examples
:let @a .= "j"
:let @q = "0" . @q
Folds (12)
zo

Open the fold under the cursor.

Mnemonic: z + o = open one fold.

Examples
zo
zc

Close the fold under the cursor.

Mnemonic: z + c = close one fold.

Examples
zc
za

Toggle the fold under the cursor (open if closed, close if open).

Mnemonic: a = alternate / toggle.

Examples
za
zR

Open ALL folds in the buffer.

Mnemonic: Capital R = "Reveal everything".

Examples
zR
zM

Close ALL folds (Maximum folding).

Mnemonic: Capital M = Maximum fold.

Examples
zM
:set fdm=<method>

Choose folding method: manual / indent / marker / syntax / expr / diff.

Mnemonic: fdm = foldmethod.

Examples
:set fdm=indent
:set fdm=marker
:set fdm=syntax
zf<motion>

Manually create a fold over the motion (works only with foldmethod=manual).

Mnemonic: zf = fold form / make.

Examples
zf3j (fold current + 3 lines below)
zfap (fold a paragraph)
zd / zE

Delete the fold under the cursor (zd) / eliminate ALL folds in the buffer (zE). Manual folds only.

Mnemonic: zd = delete one fold, zE = eliminate every fold.

Examples
zd
zE
zj / zk

Move to the start of the next fold (zj) / end of the previous fold (zk).

Mnemonic: z + j/k = move between folds, same down/up sense as j/k.

Examples
zj
zk
zr / zm

Reduce (zr) / increase (zm) the fold level by one — open or close one more layer of nested folds.

Mnemonic: zr = reduce folding (open a layer), zm = more folding.

Examples
zr
zm
zv

Open just enough folds to make the line with the cursor visible (view the cursor).

Mnemonic: zv = view the cursor line (unfold just enough).

Examples
zv
zi

Toggle folding on/off for the whole buffer (flips foldenable).

Mnemonic: zi = invert folding on/off.

Examples
zi
How do I…? (19)
How do I exit vim?

Press Esc, then type :q (quit). If you have unsaved changes use :wq (save and quit) or :q! (quit and toss changes).

Mnemonic: Esc + colon = leave the trap. q = quit, q! = quit forcefully.

Examples
:q
:wq
:q!
ZZ (= :wq)
ZQ (= :q!)
Pasting from clipboard mangles indentation

Vim auto-indents what you type — when you paste code from the OS, indentation cascades. Toggle :set paste before pasting, :set nopaste after.

Mnemonic: :set paste = "I am not typing, just pasting raw bytes".

Examples
:set paste
(paste your code)
:set nopaste
(better:) :set pastetoggle=<F2>
How do I undo? Where did Ctrl+z go?

In normal mode, press u to undo, Ctrl+r to redo. Ctrl+z suspends vim to the shell (`fg` returns).

Mnemonic: u = undo (NOT Ctrl+z). Vim was designed before Windows/Mac standardized Ctrl+z.

Examples
u
Ctrl+r
:earlier 5m (undo back to 5 minutes ago)
:later 5m
Search keeps highlighting after I find it

That is hlsearch. Run :noh once to clear; map <leader>h to it for daily life.

Mnemonic: noh = no highlight. Common in every .vimrc.

Examples
:noh
nnoremap <leader>h :noh<CR>
"E37: No write since last change"

You tried to switch buffers / quit without saving. Save with :w, force-discard with :e! / :q!, or :set hidden to allow background buffers with unsaved changes.

Mnemonic: E37 = "save first, or force with !".

Examples
:w
:q!
:set hidden
"E37: No write since last change" but I already saved!

You probably hit Ctrl+s, which is XOFF (freezes terminal) in many terminals — vim never got the signal. Use :w instead, then Ctrl+q to unfreeze if needed.

Mnemonic: Ctrl+s = freeze terminal (XOFF), Ctrl+q = unfreeze (XON).

Examples
:w
stty -ixon (disable terminal flow control)
I opened a file with vim but it is read-only

Either you opened with vim -R, or the file is owned by root. Workarounds: :w !sudo tee % > /dev/null to save through sudo, or :set noreadonly then :w! if you have perms.

Mnemonic: sudo-tee trick = pipe the buffer through sudo tee back to the file.

Examples
:w !sudo tee % > /dev/null
:set noreadonly | w!
Vim "started in REPLACE mode" / weird overwriting

You pressed Caps Lock + a or hit Insert twice. Esc + i puts you back in normal insert mode. Check :set showmode is on so you can see what mode you are in.

Mnemonic: Always glance at the status line — vim shows -- INSERT -- / -- REPLACE -- / -- VISUAL --.

Examples
Esc i
:set showmode
Why does dd "yank" instead of just deleting?

In vim, delete IS cut — it puts the deleted text into the default register. To delete without yanking, use the black-hole register: "_dd.

Mnemonic: "_ + d = throw it away (no register pollution).

Examples
"_dd
"_x
nnoremap <leader>d "_d (map <leader>d to black-hole delete)
Swap file warning: ".file.swp" already exists

Another vim is editing the same file, or it crashed last time. Press R to recover, D to delete the swap, Q to quit. If you are sure no other process — `ls -la .file.swp` then delete.

Mnemonic: R = Recover, D = Delete swap, Q = Quit, A = Abort.

Examples
(R)ecover
(D)elete
rm .myfile.swp
I hit Ctrl+s and the whole terminal froze

Ctrl+s sends XOFF, which freezes terminal output (vim looks dead but is fine). Press Ctrl+q (XON) to unfreeze. Add stty -ixon to your shell rc to disable this.

Mnemonic: Ctrl+s freezes (XOFF), Ctrl+q thaws (XON).

Examples
Ctrl+q
stty -ixon
I typed :W or :Q and got "E492: Not an editor command"

You held Shift too long — :W and :Q are not commands. Use lowercase :w and :q. Many people add command! W w and command! Q q to their vimrc to forgive this.

Mnemonic: Commands are lowercase: :w :q :wq, not :W :Q.

Examples
:w
:q
command! W w
My arrow keys insert letters like A B C D

A terminal in the wrong mode (or vi compatible mode) sends raw escape codes for arrows. Make sure your vimrc has set nocompatible, and prefer a real vim, not the bare "vi".

Mnemonic: set nocompatible fixes most "arrows type letters" weirdness.

Examples
set nocompatible
(or just use hjkl 😄)
I pasted code and indentation exploded into a staircase

Autoindent re-indents each pasted line on top of the previous one. Use :set paste first, paste, then :set nopaste. With system clipboard, "+p pastes verbatim and avoids this entirely.

Mnemonic: :set paste before pasting, or use "+p for raw clipboard paste.

Examples
:set paste
"+p
:set nopaste
I want to undo ALL my changes since opening the file

Use :e! to reload the file from disk and discard every unsaved change. (u only steps back one change at a time; :e! resets to the saved version.)

Mnemonic: :e! = re-edit, throwing away unsaved changes.

Examples
:e!
:edit!
How do I see line numbers / relative line numbers?

Run :set number for absolute line numbers, :set relativenumber for distances from the cursor (makes 5j / 12k counts obvious). Combine both for a hybrid gutter.

Mnemonic: number = absolute, relativenumber = distance-based.

Examples
:set number
:set relativenumber
:set nu rnu
I selected text but Ctrl+c / Ctrl+v does not copy to other apps

Vim has its own registers; the OS clipboard is the + register. Yank with "+y (or "+yy for a line) and paste elsewhere; from outside, paste into vim with "+p. Needs a +clipboard vim build (check :version).

Mnemonic: OS clipboard = the "+ register, not the default register.

Examples
"+yy
"+p
:version (look for +clipboard)
My search is case-sensitive (or annoyingly case-insensitive)

Set :set ignorecase to match any case, plus :set smartcase so an uppercase letter in the query forces case-sensitivity. For a one-off, append \c (insensitive) or \C (sensitive) to the pattern.

Mnemonic: ignorecase + smartcase is the sweet spot; \c / \C override per search.

Examples
:set ignorecase smartcase
/Foo\C
/foo\c
I keep landing in Ex mode with a colon prompt that will not leave

You pressed Q (old binding) and entered Ex mode. Type visual then Enter (or :vi) to return to normal mode. Many configs remap Q to avoid this trap.

Mnemonic: Ex mode escape: type :vi (or visual) + Enter.

Examples
:vi
visual<CR>

What this tool does

A searchable vim cheat sheet built for people who actually live in the terminal. 122 commands across 11 categories: modes (normal / insert / visual / command / replace), motions (hjkl, w/b/e, gg/G, 0/^/$, paragraphs and sentences, half- and full-page scroll, screen positioning, find-on-line with f/F/t/T, matching brackets, jump list), edits (i/a/o/O, x/r/s, d/c/y + motion, p/P, u/Ctrl+r, the dot command, indent, case toggle, join, text objects with i/a), search & substitute (/, ?, n/N, * #, :s and :%s with g/c flags and ranges), registers ("ay "ap, the system clipboard "+, the X11 PRIMARY "*, the black-hole "_, the yank-only 0 register, :reg), marks (ma 'a `a :marks '' :delmarks), splits and windows (:sp :vsp, Ctrl+w h/j/k/l, Ctrl+w =, Ctrl+w + and >, Ctrl+w o and q), buffers and tabs (:ls :b :bn :bp :bd, :tabnew :tabn :tabp), macros (qa, @a, @@, :let @a = …), folds (zo zc za zR zM zf, foldmethod), and the famous "How do I exit vim?" pitfalls category (paste mangles indent → :set paste; Ctrl+s freezes terminal; "E37: no write since last change"; the dd-yanks-instead-of-deletes trap and the black-hole register fix; swap file recovery; replace mode surprise). Every entry has a command, an EN+ZH explanation, a short mnemonic so you actually remember it, and one or two real examples you can copy with the inline copy button. Search runs live across command, descriptions, mnemonics and examples — type "clipboard" and the "+ register pops up. Filter by category with a single click. Fully bilingual EN/ZH (native, not translated), 100% client-side, no tracking, no ads. Pair with our Git Cheatsheet, Regex Cheatsheet, Docker Cheatsheet and Kubectl Cheatsheet for the rest of the daily-Google syntax stack.

Tool details

Input
Text
The page exposes text boxes, numeric controls, file pickers, or structured inputs depending on the tool.
Output
Live result + Copy + Preview
The result area focuses on usable output, with copy, download, or preview actions when supported.
Privacy
Browser-side processing
The main tool logic does not call an external API, so inputs normally stay in the current tab.
Save / share
No account required
Open the page and use it; whether results survive refresh depends on the tool.
Performance budget
Initial JS <= 25 KB
No WASM budget is declared, keeping the tool quick to open on mobile.
Best fit
Developer & DevOps · Developer
Category and role tags drive related tools, internal links, and quick fit checks.

How to use

  1. 1. Input

    Paste or drop your content into the tool panel.

  2. 2. Process

    Click the button. All processing is local in your browser.

  3. 3. Copy / Download

    Copy the result or download to disk in one click.

How Vim Cheatsheet fits into your work

Use it in the small gaps between coding, reviewing, debugging, and shipping.

Developer jobs

  • Formatting, validating, shrinking, or inspecting code-adjacent text.
  • Preparing snippets for documentation, tickets, commits, or handoff.
  • Checking a small payload quickly without switching tools.

Developer checks

  • Run irreversible transforms like minify or obfuscate on a copy.
  • Keep secrets out of pasted snippets unless the tool explicitly stays local.
  • Use your normal tests or linter before shipping transformed code.

Good next steps

These links move the current task into a more complete workflow.

  1. 1 SQL Cheatsheet SQL cheat sheet — 100+ statements covering SELECT, JOIN, window functions, indexing, MySQL/PostgreSQL/SQLite differences. Open
  2. 2 Git Cheatsheet Git command cheat sheet — searchable, with explanations, common mistakes, and real examples. Open
  3. 3 Docker Cheatsheet Docker command cheat sheet — 80+ commands with real examples, common mistakes, and Compose section. Open

Real-world use cases

  • First SSH into a server and git just dropped you into vim for a commit message

    You ran git commit, no -m, and now a blank vim buffer is staring at you over SSH. Press i, type your one-line message, hit Esc, then :wq and Enter. If you only meant to abort, :q! bails and git cancels the commit. Searching this sheet for "exit vim" gets you ZZ and ZQ too — the two keystrokes that save the most trips back here at 2am.

  • Editing an nginx or systemd config where the system vim has no clipboard support

    You SSH into a box, open /etc/nginx/nginx.conf, and "+y does nothing because the stock vim is built -clipboard. Filter to Registers, copy with yy into the unnamed register, navigate, then p. For getting a config block onto your laptop, visual-select with V, yank, and rely on your terminal's mouse selection — the sheet's clipboard entry spells out the +clipboard check and the OSC-52 fallback.

  • A reviewer asks you to rename one variable across 40 lines of a file

    Instead of 40 manual edits, jump to the first hit with /oldName, change it with cw, type newName, Esc. Then press . on every next match — the dot command repeats the whole change. For a blind sweep, :%s/oldName/newName/gc replaces across the file and the c flag asks y/n at each of the 40 spots so you never clobber a substring you meant to keep.

  • Recording a macro to reformat 200 log lines that all need the same surgery

    Each line needs a timestamp stripped and a comma added. Record once: qa, do the edits on line one, q to stop. Then 199@a replays it down the file in one shot. Search this sheet for "macro" to get qa / @a / @@ and the :let @a trick for editing a macro that fumbled one keystroke — far faster than 200 hand edits.

Common pitfalls

  • Typing :q with unsaved changes and panicking at "E37" — it is not an error you broke, just add ! (:q!) to discard or use :wq to save.

  • Pasting from the browser without :set paste first, so autoindent cascades every line right; toggle :set paste before, :set nopaste after.

  • Assuming "+y works everywhere — run vim --version | grep clipboard first; a -clipboard build silently does nothing and you lose the yank.

Privacy

This cheat sheet is a static reference that runs entirely in your browser. Your search queries and the category you filter to never leave the page — there is no backend call, no analytics on what you look up, and nothing is written to the URL. You can read it offline once the page has loaded.

FAQ

Tool combos

Folks in your role tend to reach for these alongside this tool.

Made by Toolora · 100% client-side · Updated 2026-06-13