How do I prepend a custom persistent undo directory while keeping existing undodir paths in Vim?
:set undodir^=$HOME/.vim/undo//
If you already have an undodir configured by a distro config or plugin, replacing it outright can remove fallback paths you still want.
category:
config
tags:
#config
#undo-redo
#options
#ex-commands
How do I clear undo history for the current buffer in Vim?
:let s:u=&l:undolevels | setlocal undolevels=-1 | execute "normal! a\<BS>\<Esc>" | let &l:undolevels=s:u
Sometimes you finish a risky refactor and want a clean undo boundary before handing the buffer off or continuing with unrelated edits.
category:
config
tags:
#undo-redo
#config
#command-line
#advanced
How do I merge consecutive edits so they undo in a single step?
By default, separate edits often become separate undo entries, which makes replaying or backing out a multi-part change noisy.
category:
editing
tags:
#editing
#undo-redo
#ex-commands
#refactoring
How do I append text with :normal without creating an extra undo step?
:undojoin | normal! A;<CR>
When you automate edits from Ex commands, Vim usually creates a separate undo entry for each change.
category:
command-line
tags:
#command-line
#undo-redo
#ex-commands
#editing
How do I reindent the whole buffer without adding jumplist entries?
:keepjumps normal! gg=G<CR>
Whole-buffer reindent is common, but doing it naively can pollute your jumplist and break navigation flow during review.
category:
command-line
tags:
#command-line
#formatting
#undo-redo
#workflow
How do I navigate Vim's undo tree in chronological order to recover changes from an abandoned undo branch?
Vim's undo history is a tree, not a linear stack.
category:
navigation
tags:
#navigation
#undo-redo
#undo-tree
How do I undo or redo to a specific point in time using time-based undo navigation?
:earlier {time} and :later {time}
Vim's :earlier and :later commands let you navigate the undo history by elapsed time rather than by edit count.
category:
command-line
tags:
#undo-redo
#ex-commands
#editing
How do I navigate to an older undo state that is not on my current undo branch?
Vim's undo history is a tree, not a linear stack.
category:
editing
tags:
#undo-redo
#navigation
#normal-mode
How do I undo all changes made in the last N minutes using time-based undo?
Vim's :earlier command lets you travel back through the undo history by wall-clock time rather than by the number of changes.
category:
editing
tags:
#undo-redo
#editing
#ex-commands
How do I jump directly to a specific point in the undo history by change number?
:undo {N} lets you jump directly to the undo tree state after change number N was applied.
category:
editing
tags:
#undo-redo
#editing
#advanced
How do I cycle through the numbered delete registers using the dot command?
When you paste from a numbered register with "1p, Vim's dot command (.
category:
registers
tags:
#registers
#editing
#normal-mode
#undo-redo
How do I move the cursor in insert mode without creating an undo break point?
By default, moving the cursor with arrow keys while in insert mode creates an undo break — meaning a subsequent u will undo only back to when you last moved,
category:
editing
tags:
#insert-mode
#undo-redo
#editing
#advanced
How do I discard all unsaved changes and reload the file from disk in Vim?
:e! forces Vim to reload the current file from disk, discarding every unsaved change in the buffer.
category:
buffers-windows
tags:
#buffers-windows
#editing
#undo-redo
#ex-commands
How do I re-insert the text from my last insert session and immediately return to normal mode?
Pressing (Ctrl + @, which is the NUL character) in insert mode inserts the same text that was typed during the most recent insert session, then immediately retu
category:
editing
tags:
#insert-mode
#editing
#undo-redo
How do I manually save the undo history for a file to a separate undo file in Vim?
The :wundo {file} command writes the current buffer's entire undo history to a file on disk.
category:
command-line
tags:
#undo-redo
#command-line
#editing
How do I navigate Vim's undo tree branches to access states that u and Ctrl-R can't reach?
Vim's undo history is a tree, not a linear stack.
category:
editing
tags:
#undo-redo
#normal-mode
#editing
How do I undo or redo all changes made within a specific time window in Vim?
:earlier {N}m and :later {N}m
Vim's :earlier and :later commands let you travel through your edit history by wall-clock time rather than by individual undo steps.
category:
command-line
tags:
#undo-redo
#ex-commands
#editing
How do I view all available branches in Vim's undo tree to recover changes that u and Ctrl-R can't reach?
Vim's undo history is a tree, not a linear stack.
category:
editing
tags:
#undo-redo
#editing
#command-line
How do I travel backward through undo history by time rather than by change count?
Vim's :earlier and :later commands let you travel through undo history using real-world time intervals instead of individual change counts.
category:
editing
tags:
#undo-redo
#ex-commands
#editing
How do I undo all changes made within the last hour using time-based undo?
Vim's undo history is annotated with timestamps, allowing you to travel back to any point in time using :earlier and forward using :later.
category:
command-line
tags:
#undo-redo
#ex-commands
#normal-mode