vim redo is the operation of reversing an undo in the Vim text editor, executed via Ctrl+r in Normal mode or the :redo Ex command. It restores the most recently undone change.
# Normal mode
Ctrl+r # Redo one change
{count}Ctrl+r # Redo count changes (e.g., 5Ctrl+r)
# Command-line mode
:redo # Redo one change (same as Ctrl+r)
:later [N] # Redo N changes (time- or count-based)
:later [N]s # Redo N seconds forward in undo history
:later [N]m # Redo N minutes forward
:later [N]h # Redo N hours forward
:later [N]d # Redo N days forward
Vim keeps a full history of every change during a session, including after saves. Redo operates on the linear undo stack; for branched history, use g- and g+.
Options and Flags
| Command/Flag | Type | Default | Description |
|---|---|---|---|
{count}Ctrl+r |
Prefix | 1 | Redo the last N undone changes. |
:redo |
Ex command | — | Redo one change. Accepts count: :redo 5. |
:later N |
Ex command | — | Go forward N changes or time units. Primary redo command in time mode. |
:earlier N |
Ex command | — | Go backward N changes or time units. Alias for undo. |
Usage Examples
Baseline undo/redo in Normal mode
# Insert "hello" then undo it twice, redo once
ihello
Esc
u # Undo insertion of "hello"
u # Undo blank (no prior change, so nothing)
Ctrl+r # Redo the insertion of "hello" (one change)
Context: After accidentally undoing too far, Ctrl+r restores the most recently undone change. Requires the buffer to have an undo history; otherwise, E22: No undo history appears.
Redo a specific number of changes
# Make three edits, undo two, redo only the first undone edit
iedit1
Esc
iedit2
Esc
iedit3
Esc
uu # Undo edit3 and edit2
3Ctrl+r # Redo three changes (edit2 and edit3, but only two exist → redo both)
Context: A count prefix jumps multiple steps without repeated keystrokes. If the count exceeds available redo steps, Vim redoes all remaining undone changes.
Time‑based redo with :later
# Make changes over 2 minutes, then jump back 30 seconds
:earlier 2m # Undo changes made in the last 2 minutes
:later 30s # Redo forward 30 seconds, restoring intermediate state
Context: The :later command accepts time suffixes (s, m, h, d) to navigate forward by a duration. This is useful for correcting an over-undo by a known time interval.
Troubleshooting & Common Errors
| Error Message | Root Cause | Resolution Command |
|---|---|---|
E22: No undo history |
No changes have been undone yet; nothing to redo. | Make a change, then undo it first: iXEscu then Ctrl+r. |
E23: No redo history |
You have already restored all undone changes. | Check undo tree with :undolist; use g-/g+ for non‑linear navigation. |
E21: Redo cannot be repeated |
Attempted to repeat a redo with the dot command (.). |
Use Ctrl+r again; the dot command only repeats the original change, not the redo. |
Performance Considerations
Undo history size and disk persistence affect redo latency. Tune these settings in .vimrc to balance memory and speed:
- undolevels — maximum number of saved changes. Default 1000; set
:set undolevels=5000(watch memory). Use-1for unlimited (risky on huge files). - undoreload — saves undo information when reloading a file. Default 0 (off). Enable with
:set undoreload=10000to keep a change window across reloads. - undofile / undodir — persistent undo files. Disable on network filesystems with
:set noundofileto avoid latency.
Check current settings:
:set undolevels?
:set undoreload?
:set undodir?
Frequently Asked Questions
What is the difference between u (undo) and Ctrl+r (redo) in Vim?
In Normal mode, u reverts the most recent change; Ctrl+r reapplies the most recently undone change. Both operate on the linear undo stack. For branched history, use g- and g+.
When should I use g+ instead of Ctrl+r for redo?
Use g+ to redo in a branched undo history; Ctrl+r only works along the linear trunk. After g- to an alternate state, g+ redoes forward along that branch.
" undo then switch branch
u " undo one change
g- " go to older state on alternate branch
g+ " redo forward along the alternate branch
How do I fix E21: Cannot redo - no previous undone change?
Ensure you have undone a change first ( u ) or increase undolevels. Check history with :undolist. If empty, no redo possible. Set undolevels=1000 in .vimrc and enable undofile for persistence across sessions.
Does Ctrl+r redo work on all platforms and modes?
Yes, in Normal mode Ctrl+r is universally mapped to redo on Windows, Linux, and macOS. In Insert mode, Ctrl+r {register} inserts register content. If a terminal intercepts Ctrl+r, use :redo or remap with nnoremap <C-r> :redo<CR>.
What is the fastest way to redo multiple undone changes?
Use a count prefix: 3Ctrl+r redoes three changes. Equivalent Ex command: :3redo. For repeated single redo, hold Ctrl+r after the first count or use g+ with a count.

Command Line Expert & Software Engineer
Welcome! I’m Thomas Heinrich, a software engineer and system administrator with a deep passion for the Command Line Interface (CLI). With years of experience navigating the terminal, building backend architectures, and automating server deployments, I created this space to share practical, real-world terminal knowledge.
Whether you are a beginner taking your first steps in a Linux environment or a seasoned DevOps engineer looking to optimize your deployment scripts, you will find actionable solutions here. My goal is to help you ditch the mouse, speed up your workflow, and harness the full power of the command line.