0

Without 'undofile', one can hold u or execute undo 0.

With 'undofile', everything changed, hold u will undo changes made in older sessions, undo 0 will undo the entire undo history, they became useless.

The :earlier 2h family command only works on certain conditions, it's not so useful if you create a new vim session in a short time after you close one.

I know the undotree plugin, but have no idea how to use it to do this job, trying saved text state is not an option.

5
  • 1
    If you havent saved yet, :edit! will work
    – D. Ben Knoble
    Dec 2 '19 at 1:20
  • 2
    Not sure this is what you want, but you could try sth like this: 0x0.st/zlTN.txt Alternatively, you may be interested in this question, and in this answer. Note that the helper functions are not needed anymore (changenr() and undotree().seq_cur should be reliable), at least if your Vim includes 8.0.1290.
    – user938271
    Dec 2 '19 at 2:10
  • Another thing I want to add—this is a non-issue for me, as I’ve never needed to “hold undo”—git makes tracking changes so much easier. Undo is a convenience, one I’m willing to lose (just a bag of files and data). Git helps make it more permanent, especially when I distribute the repo
    – D. Ben Knoble
    Dec 2 '19 at 2:28
  • @user938271 Thanks, very helpful. Since It's been discussed plenty in that question, I will close this question.
    – dedowsdi
    Dec 2 '19 at 2:49
  • 1
    @D.BenKnoble Not everything is in a git repo, git also won't help if you have not stage your changes.
    – dedowsdi
    Dec 2 '19 at 2:59

Browse other questions tagged or ask your own question.