In Vim normal mode, a change was undone with u.
Cancel that undo and apply the change again.
Which key sequence is appropriate?
In Vim, Ctrl-r redoes a change that was undone with u.
Detailed explanation
Ctrl-rCorrect. Ctrl-r reapplies the change that u removed.
Correct. Ctrl-r reapplies the change that u removed.
Ctrl-uIncorrect. Ctrl-u scrolls or moves the view; it is not redo.
Incorrect. Ctrl-u scrolls or moves the view; it is not redo.
uIncorrect. u undoes another change.
Incorrect. u undoes another change.
rIncorrect. r replaces one character under the cursor.
Incorrect. r replaces one character under the cursor.
Try it yourself
An example you can run in a temporary verification environment.
printf 'one\ntwo\n' > sample.txt; vim -Nu NONE -i NONE -n -es sample.txt -c 'normal! ggdd' -c 'normal! u' -c 'execute "normal! \<C-r>"' -c 'wq'; cat sample.txtExpected result
twoKey points
- Ctrl-r is redo
- u is undo
- r replaces one character
Notes
- Environment: Vim 9.x
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.