The Universal Grammar

[count] [register] operator [count] motion

Keys: d, c, y, >, <, =, gU, gu, g~, w, iw, ip, $, %

Vim is a tiny language: verbs (operators) compose with nouns (motions and text objects). Once you see the grammar, every key falls into place.

Almost every command in Vim follows one shape:

[count] ["reg] operator [count] motion

Read it as a sentence: do this thing, optionally to register r, this many times, to this stretch of text. (Registers are named clipboards โ€” the "a prefix means "into register a"; the full treatment is in Registers.) Concrete examples:

Command Reads as
dw Delete one word forward
3dw Delete three words forward
d3w Delete three words forward (counts multiply, but here one of them is 1)
ciw Change the inner word the cursor is on
y$ Yank from cursor to end of line
>ip Indent inner paragraph
"ayy Yank this line into register a
gUiw Uppercase the inner word

The verbs (operators)

Operator Meaning
d Delete (cut)
c Change (delete then enter insert mode)
y Yank (copy)
> Indent right
< Indent left
= Auto-indent / format
gU Uppercase
gu Lowercase
g~ Toggle case
gq Format (line-wrap)
! Filter through external command

The nouns (motions and text objects)

Anything that moves the cursor in normal mode is a motion. After an operator, the same motion describes the range the operator acts on. So w alone moves the cursor a word forward; dw deletes the same span.

Noun kind Examples
Word / WORD w, b, e, W, B, E
Line 0, ^, $, _, g_
File gg, G, {n}G
Find on line f{c}, F{c}, t{c}, T{c}, ;, ,
Search /{pattern}, ?{pattern}, n, N, *, #
Sentence / paragraph (, ), {, }
Bracket match %
Inner / around text object iw, aw, i", a(, ip, at

Text objects (the i / a rows) are nouns that describe structure rather than a path: i means the inner contents (e.g. iw = the word the cursor is in), a means the object plus its delimiters (e.g. a" = a quoted string including the quotes). The full treatment is in Text Objects โ€” for now, treat them as nouns like any other.

The Vim Grammar in Action

Worked example โ€” operator + motion = sentence

The grammar in three keystrokes.

Step 1 ยท Cursor on q.
Cursor on `q`.

normal mode. We'll run dw: the delete operator with the word motion.

Step 2 ยท dw ยท dw โ€” quick deleted.
`dw` โ€” `quick ` deleted.

Operator d (verb) plus motion w (noun). The same grammar applies for any operator+motion pair.

Step 3 ยท gUw ยท gUw โ€” BROWN uppercased.
`gUw` โ€” `BROWN` uppercased.

Swap the operator for gU (uppercase), keep motion w. Free upgrade โ€” every motion works with every operator.

See also: The Vim Grammar, Delete, Change, Yank and Put, Inner Word vs Around Word