editing

u / Ctrl-R

u undoes the last change; Ctrl-R redoes it. Vim has a full undo TREE (see :undolist and g-/g+) but for day-to-day work these two keys are enough.

u  <C-r>  (normal mode)

Variations

Keystroke Effect
5u Undo the last 5 changes
U Undo ALL changes on the current line (not a step-back — different feature)
g- Go to older text state (undo branch)
g+ Go to newer text state

Examples

u

Undo last change

<C-r>

Redo (re-apply what u just undid)

:earlier 5m

Roll file state back 5 minutes

Gotcha

One 'change' is everything you did between two Escapes in insert mode — a whole paragraph typed in one insert is a single u. If you leave insert mode often, you get finer-grained undo.

Related

← All Vim commands · Vim cheat sheet