Undo as a Tree
g- and g+ walk by time. :undolist shows the branches.
Vim's undo isn't a stack โ it's a tree. Every undo branch is preserved. g- and g+ walk by chronological time;:undolistshows all branches;:earlier/:laterjump by time intervals.
In most editors, undo is a stack: redo a mistake, the original is gone forever. In Vim, undo is a tree โ every branch is kept.
| Key | Action |
|---|---|
| u | Undo previous change (along current branch) |
| Ctrl-R | Redo (along current branch) |
| g- | Go to OLDER state by chronological time |
| g+ | Go to NEWER state by chronological time |
| `:undolist` | Show the undo tree |
| `:earlier5m` | State as of 5 minutes ago |
| `:later30s` | 30 seconds forward |
| `:earlier10` | 10 changes back |
Watch
See also: Undo and Redo