Can Vim restore the state exactly after an undo?
For example, if I'm in the end of a word and I type 'diwu', the cursor ends up at the start of the word.
Same applies if I have something selected in visual mode (after undo I'd like it to go back to the visual selection I had before the operation I've just undone).
Sorry if sta开发者_如何转开发ckoverflow isn't the best place for this (seemed to be the best option looking around).
I'm not sure it can/should be automated with a mapping but in your first case I would create a mark with ma
then do the deletion/undo, then type `a
to position the cursor at the mark.
In the second case, gv
reselects the previous visual selection.
The closest I came:
the quick brown fox jumped over the lazy moon
cursor here ----- ^
Execute
madiwu`a
It requires you to explicitely save the location before the edit/undo so it is pretty useless unless you know beforehand that you are going to revert an edit
ma
(save current position in mark 'a')diw
(delete inner word, 'jumped ')u
(undo that change, cursor ends up at 'j' of 'jumped')`a
(jump to 'a' marker)
精彩评论