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
| Keys | What they do |
|---|---|
| u | Undo the last change |
| Ctrl+r | Redo what you just undid |
3u | Undo three changes |
:earlier 10m | Wind the file back ten minutes |
:later 10m | And 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