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; :undolist shows all branches; :earlier/:later jump 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 |
| :earlier 5m | State as of 5 minutes ago |
| :later 30s | 30 seconds forward |
| :earlier 10 | 10 changes back |
Watch
- ๐บ #0481 Undo Branches (not yet published)
- ๐บ #0483 The . Register (not yet published)
See also: Undo and Redo