Imagine a text file with some words on the first line, one-thousand blank lines, and some text on the last line.
this is a first line of text. <1000 blank lines> Last line of text.
From the first line make a change and go to the last line by typing exactly:
A This change will be invisible when undone from offscreen.<ESC>G.
The text is now:
this is a first line of text. This change will be invisible when undone from offscreen. <1000 blank lines> Last line of text.
and the cursor is on the last line and you can't see the first line.
We can press
u to undo the change, but because we started offscreen from where the change actually occurred, we don't see what was undone; we just see the text as it was before the change and we have to remember what the change was that was just undone. This was a simple example but what the offscreen change was can be difficult when acutally working.
So my question is, does anyone know a way to 'preview' offscreen undos before they come into effect so that you can actually see specifically what is being undone? Or some other similar solution.
umoves the cursor (and hence the view) back to the changed line
u, there’s the undotree and some plugins (at least one of which includes a small diff preview)
<c-r>. For those times when multiple steps are impacted I fire up undotree which opens up two windows: the undo history and a diff that shows what changed between the currently selected history entry and the previous entry.