Overview
Vim’s learning curve is real but front-loaded. Once the modal model clicks, editing speed compounds. This card covers the motions, operators, and commands worth internalizing. For terminal multiplexing alongside Vim, see tmux-commands.
Modes
Every keystroke’s meaning depends on the current mode.
| Mode | How to enter | Purpose |
|---|---|---|
| Normal | Esc or Ctrl-[ | Navigate and operate. The default mode. |
| Insert | i, a, o, I, A, O | Type text. |
| Visual | v (char), V (line), Ctrl-v (block) | Select text for an operation. |
| Command | : | Enter ex commands (save, quit, substitute). |
| Replace | R | Overwrite characters in place. |
Return to Normal with Esc from any mode. When confused, press Esc twice.
Motions
Motions move the cursor. Prefix with a count: 3w moves three words forward.
| Motion | What it does |
|---|---|
h j k l | Left, down, up, right. |
w / W | Forward one word / WORD (whitespace-delimited). |
b / B | Back one word / WORD. |
e / E | Forward to end of word / WORD. |
0 | Start of line. |
^ | First non-blank character of line. |
$ | End of line. |
gg | First line of file. |
G | Last line of file. |
{ / } | Previous / next empty line (paragraph). |
% | Jump to matching bracket, paren, or brace. |
f{c} / F{c} | Jump to next / previous occurrence of character c on the line. |
t{c} / T{c} | Jump to just before / after c. |
Ctrl-d / Ctrl-u | Scroll half page down / up. |
:42 | Jump to line 42. |
f then ; to repeat the search forward; , to repeat backward.
Operators
Operators act on a motion: operator + motion or operator + text-object.
| Operator | Action |
|---|---|
d | Delete (cut). |
c | Change (delete and enter Insert). |
y | Yank (copy). |
> / < | Indent / de-indent. |
= | Auto-indent. |
gU / gu | Uppercase / lowercase. |
Doubles apply to the whole line: dd deletes a line, yy yanks a line, cc changes a line.
Common text objects used with operators:
| Text object | Selects |
|---|---|
iw / aw | Inner word / a word (includes surrounding space). |
i" / a" | Inside / around double quotes. |
i( / a( | Inside / around parentheses. |
i{ / a{ | Inside / around braces. |
it / at | Inside / around an HTML tag. |
ip / ap | Inner / a paragraph. |
ci" changes everything inside double quotes. da( deletes a parenthesized expression including the parens.
Search and replace
Search is a motion; use it to drive operators.
| Command | What it does |
|---|---|
/pattern | Search forward. n next, N previous. |
?pattern | Search backward. |
* / # | Search forward / backward for the word under cursor. |
:%s/old/new/g | Replace all occurrences in the file. |
:%s/old/new/gc | Replace with confirmation at each occurrence. |
:10,20s/old/new/g | Replace in lines 10 to 20. |
:'<,'>s/old/new/g | Replace in visual selection (populated automatically after V). |
:noh | Clear search highlight. |
Patterns use Vim regex. Use \v (very magic mode) for PCRE-like syntax: :%s/\v(\w+)@(\w+)/\1 at \2/g.
Registers and macros
Registers are named clipboards; macros record keystrokes into a register.
| Command | What it does |
|---|---|
"ayy | Yank a line into register a. |
"ap | Paste from register a. |
"+y | Yank to the system clipboard. |
"+p | Paste from the system clipboard. |
:reg | Show all register contents. |
qa | Start recording a macro into register a. |
q | Stop recording. |
@a | Play macro a. |
10@a | Play macro a ten times. |
@@ | Replay the last macro. |
Design macros to be repeatable: end with a motion that positions the cursor for the next invocation.
Common gotchas
- Pressing
uin Insert mode undoes a character; in Normal mode it undoes the last change. If your undos feel too granular, break insert sessions withEscbetween logical chunks. xdeletes into the unnamed register, overwriting your last yank. Yank into a named register ("ay) before deleting if you need to paste the yanked text later.:q!discards unsaved changes without confirmation. Use:wqato write all buffers and quit.ddon a blank line still puts the newline in the register."_ddsends the delete to the black-hole register and leaves the clipboard alone.- Vim regex is not PCRE.
+requires\+without\v. Use\vat the start of a pattern to enable very magic mode and write+,(),|without backslashes. :set pastebefore pasting from the system clipboard in Insert mode to prevent autoindent from mangling indentation. Reset with:set nopaste. Neovim does not need this.