0

I'm using U in normal mode to undo steps in vim, I wonder how to set a sort of a bookmark and create a undo command to undo steps/reverse to the bookmark moment in Vim. This would be nicer than just keep pressing U.

  • What about using git? I think this is one of the purposes of version control. git provides also the feature called stash to keep your uncommitted changes when checking out a previous commit. – Hotschke Mar 6 '19 at 15:59
  • 1
    If git is too much for what you want, consider plugins which visualize the undo steps as a tree with timestamps, e.g. github.com/mbbill/undotree. – Hotschke Mar 6 '19 at 16:06
  • @Hotschke I'm trying to avoid git for this, sometimes I need to test a several lines and see the result and come back to the moment before test. for just steps under 10, I don't want to use git. – SLN Mar 6 '19 at 16:07
  • 2
    My histwin plugin allows to define marks in the undo history – Christian Brabandt Mar 6 '19 at 16:10
  • 1
    BTW: for undotree see this wishlist request. – Christian Brabandt Mar 6 '19 at 16:24
2

Via Plugins

Via External Tooling

Consider using VCS systems like git or mercurial (the two leading distributed systems).


Aside: your question mentions capital U, which has very different effects from u. They both have their uses, but my goto is usually u because it truly "undoes."

Plus, <Leader>u makes a good mapping for, e.g., undotree’s command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.