vimtricks.wiki Concise Vim tricks, one at a time.

How do I redo an undone change in Vim?

Answer

<C-r>

Explanation

The <C-r> (Ctrl+r) command redoes the last change that was undone with u. Vim maintains a full undo/redo history, so you can move back and forth through your edits freely.

How it works

  • u undoes the last change
  • <C-r> redoes the last undone change
  • You can press <C-r> repeatedly to redo multiple undone changes

Example

Given the text:

Hello, world!

You delete world! with daw, leaving:

Hello, 

Pressing u undoes the deletion, restoring Hello, world!. Pressing <C-r> redoes it, deleting world! again.

Tips

  • Vim has an undo tree, not just a linear history — use :undolist to see the branches
  • Use U to undo all changes on the current line (this counts as its own change)
  • Use :earlier 5m to jump to the buffer state from 5 minutes ago
  • Use :later 5m to move forward in time
  • If you accidentally undo too far, <C-r> will get you back

Next

How do I edit multiple lines at once using multiple cursors in Vim?