Oct 10, 2018

[HDGEM] How to Undo and Redo in Vim

To undo recent changes, from normal mode use the undo command:

u: undo last change (can be repeated to undo preceding commands)
Ctrl-R: Redo changes which were undone (undo the undos). Compare to . to repeat a previous change, at the current cursor position. Ctrl-R (hold down Ctrl and press r) will redo a previously undone change, wherever the change occurred.
A related command is:

U: return the last line which was modified to its original state (reverse all changes in last modified line)
U is not actually a true "undo" command as it does not actually navigate undo history like u and CTRL-R. This means that (somewhat confusingly) U is itself undo-able with u; it creates a new change to reverse previous changes.

U is seldom useful in practice, but is often accidentally pressed instead of u, so it is good to know about.

--
Posted By Blogger to HDGEM at 3/23/2017 08:37:00 AM