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.– HotschkeMar 6, 2019 at 15:59
-
1If 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.– HotschkeMar 6, 2019 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.– SLNMar 6, 2019 at 16:07
-
2My histwin plugin allows to define marks in the undo history– Christian BrabandtMar 6, 2019 at 16:10
-
1BTW: for undotree see this wishlist request.– Christian BrabandtMar 6, 2019 at 16:24
1 Answer
Via Plugins
- mbbill/undotree (this is what I use)
- simnalamburt/vim-mundo
- chrisbra/histwin
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.