Vim Cheat Sheet
Every Vim command you need, searchable and copyable.
Modes
i / aInsert before / after the cursor
I / AInsert at line start / line end
o / OOpen a new line below / above
v / V / Ctrl-vVisual mode: characters / lines / block
Esc or Ctrl-[Return to normal mode
:Enter command-line mode
RReplace mode (overwrite characters)
Movement
h j k lLeft, down, up, right
w / b / eNext word start / previous word start / word end
0 / ^ / $Line start / first non-blank / line end
gg / GFirst line / last line
{n}G or :{n}Go to line n
{ / }Previous / next paragraph
%Jump to the matching bracket
Ctrl-d / Ctrl-uScroll half page down / up
f{c} / t{c}Jump to / just before the next character c on the line
H / M / LTop / middle / bottom of the screen
Editing
x / XDelete character under / before the cursor
dd / DDelete the line / delete to the end of line
dw / d$ / d0Delete word / to line end / to line start
cc / cw / CChange line / word / to end of line
r{c} / JReplace one character / join with next line
yy / ywYank (copy) line / word
p / PPaste after / before the cursor
u / Ctrl-rUndo / redo
.Repeat the last change
>> / <<Indent / unindent the line
~ / gU / guToggle case / uppercase / lowercase (with motion)
Text objects
diw / dawDelete inner word / word with surrounding space
ci" / ci(Change text inside quotes / parentheses
dap / yapDelete / yank a paragraph
dit / citDelete / change inside an HTML tag
vi{ / va{Select inside / including curly braces
Search and replace
/patternSearch forward
?patternSearch backward
n / NNext / previous match
* / #Search the word under the cursor forward / backward
:%s/old/new/gReplace all occurrences in the file
:%s/old/new/gcReplace all with confirmation
:nohClear search highlighting
Files, buffers and windows
:wSave
:q / :q!Quit / quit without saving
:wq or ZZSave and quit
:e fileOpen a file
:ls / :b{n}List buffers / switch to buffer n
:sp / :vspSplit window horizontally / vertically
Ctrl-w h/j/k/lMove between split windows
:tabnew / gtNew 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}pYank into / paste from a named register
"+y / "+pCopy 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
- Modes and escape. Know that Esc returns to normal mode and that i, a, o start typing.
- 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.
- 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.
- 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.
- 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
How do I exit Vim?
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.
What is the difference between normal, insert and visual mode?
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.
How do I copy and paste in Vim?
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.
How do I search and replace across a whole file?
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.