Vim Scoops / Lessons / Undo and redo

How to undo and redo in Vim

Press u in Normal mode to undo your last change, and Ctrl+r to redo it. Each u steps back one more change.

The keys

KeysWhat they do
uUndo the last change
Ctrl+rRedo what you just undid
3uUndo three changes
:earlier 10mWind the file back ten minutes
:later 10mAnd forward again

One change is one undo. Everything you type between i and Esc counts as one change, so u takes back the whole burst at once.

Vim keeps the full history, not just the last step. That's why :earlier and :later can move through it by time.

Related

Want all of Vim, in order? Vim Scoops is a free game that starts at h j k l and builds up to macros.

Play the full game