Vim Cheat Sheet

Every Vim command you need, searchable and copyable.

​
ModesMovementEditingText objectsSearch and replaceFiles, buffers and windowsMacros, marks and registers
54 entries

Modes

i / a

Insert before / after the cursor

I / A

Insert at line start / line end

o / O

Open a new line below / above

v / V / Ctrl-v

Visual mode: characters / lines / block

Esc or Ctrl-[

Return to normal mode

:

Enter command-line mode

R

Replace mode (overwrite characters)

Movement

h j k l

Left, down, up, right

w / b / e

Next word start / previous word start / word end

0 / ^ / $

Line start / first non-blank / line end

gg / G

First line / last line

{n}G or :{n}

Go to line n

{ / }

Previous / next paragraph

%

Jump to the matching bracket

Ctrl-d / Ctrl-u

Scroll half page down / up

f{c} / t{c}

Jump to / just before the next character c on the line

H / M / L

Top / middle / bottom of the screen

Editing

x / X

Delete character under / before the cursor

dd / D

Delete the line / delete to the end of line

dw / d$ / d0

Delete word / to line end / to line start

cc / cw / C

Change line / word / to end of line

r{c} / J

Replace one character / join with next line

yy / yw

Yank (copy) line / word

p / P

Paste after / before the cursor

u / Ctrl-r

Undo / redo

.

Repeat the last change

>> / <<

Indent / unindent the line

~ / gU / gu

Toggle case / uppercase / lowercase (with motion)

Text objects

diw / daw

Delete inner word / word with surrounding space

ci" / ci(

Change text inside quotes / parentheses

dap / yap

Delete / yank a paragraph

dit / cit

Delete / change inside an HTML tag

vi{ / va{

Select inside / including curly braces

Search and replace

/pattern

Search forward

?pattern

Search backward

n / N

Next / previous match

* / #

Search the word under the cursor forward / backward

:%s/old/new/g

Replace all occurrences in the file

:%s/old/new/gc

Replace all with confirmation

:noh

Clear search highlighting

Files, buffers and windows

:w

Save

:q / :q!

Quit / quit without saving

:wq or ZZ

Save and quit

:e file

Open a file

:ls / :b{n}

List buffers / switch to buffer n

:sp / :vsp

Split window horizontally / vertically

Ctrl-w h/j/k/l

Move between split windows

:tabnew / gt

New tab / next tab

Macros, marks and registers

q{a-z}

Start recording a macro into a register; press q again to stop

@{a-z} / @@

Play a macro / repeat the last macro

m{a-z}

Set a mark

'{a-z} / `{a-z}

Jump to the mark line / exact position

"{a-z}y / "{a-z}p

Yank into / paste from a named register

"+y / "+p

Copy to / paste from the system clipboard

Vim Cheat Sheet

Vim is a modal editor: the same keys do different things depending on the mode you are in. That is why it feels strange at first and fast later. This cheat sheet collects the commands that cover most daily work in one searchable page, grouped by task so you can scan a section or type a word such as "delete" or "split" into the search box.

How to use this sheet

Type in the search field to filter every section at once, or use the chips under it to jump to a group. The copy button next to each row copies the key sequence. Entries written like {n} or {c} are placeholders: replace them with a number or a character.

Learn Vim in this order

  1. Modes and escape. Know that Esc returns to normal mode and that i, a, o start typing.
  2. Movement. Learn h, j, k, l, then w, b, 0, $, gg and G. Moving by words and lines is quicker than holding an arrow key.
  3. Operators plus motions. Commands such as d (delete), c (change) and y (yank) combine with any motion: dw deletes a word, c$ changes to the end of the line, y} yanks a paragraph.
  4. Text objects. ci" changes the text inside quotes, dap deletes a paragraph, and vi{ selects the inside of a block. These are the biggest time savers.
  5. Repeat and undo. The dot command repeats your last change, and u and Ctrl-r undo and redo.

Tips for faster editing

Count prefixes multiply commands: 3dd deletes three lines and 5j moves down five lines. Macros (q to record, @ to replay) automate repetitive edits. Marks let you jump back to a place with a single key. Splits and tabs keep several files in view without leaving the terminal.

Works in other tools

Most of these keys also work in Neovim, in the vi mode of your shell, and in the Vim extensions for VS Code, JetBrains IDEs and browsers, so the time you invest carries over.

Frequently Asked Questions

Press Esc to be sure you are in normal mode, then type :q and Enter to quit. Use :q! to quit and discard changes, :wq or ZZ to save and quit.

Normal mode is for moving and running commands, insert mode types text like an ordinary editor, and visual mode selects text so that the next command acts on the selection. Esc always takes you back to normal mode.

Yank with yy (line) or y plus a motion, then paste with p (after the cursor) or P (before). To use the system clipboard, yank with "+y and paste with "+p when your Vim was built with clipboard support.

Use :%s/old/new/g. Add c at the end (:%s/old/new/gc) to confirm each replacement, and run :noh to remove the search highlight afterwards.