6

I seem to be unable to undo something in a file I saved, despite that the history of changes shows up with I press :changes. So the change history is known to vim but I cannot access it?

I thought it was possible to go back to previous changes even after you save the file, but perhaps I am wrong. I also the get the "Already at" message with g- and g+.

1
  • 2
    You should be able to navigate the undo history independently from saving or not. You could have a look at :h :undolist to make sure you have things to undo. You should also have a look at how to debug my vimrc in case the issue comes from your configuration. Finally you should give us a detailed list of the actions you are doing (e.g. open a new buffer, append text, save with :w, press u), the results you got and the results you expected. This would be easier to help you debug this.
    – statox
    Commented Jul 2, 2020 at 7:55

1 Answer 1

11

The change list is a different thing from the undo list.

The change list is a list of locations of changes, and it can be viewed with :changes and navigated with e.g. g; and g,.

The g+ and g- commands that you’re using move instead through the undo list. This is a tree of different file states: it’s what you are navigating when you undo and redo changes. The undo list can be viewed with :undolist.

Vim only persists the undo list between sessions when you have undo persistance switched on: it is switched off by default.

Try adding set undofile to your .vimrc or read the documentation at :help undo-persistence for full details.

1
  • wow, that really clears things up. I didn't realize they were distinct lists!
    – johnbakers
    Commented Jul 2, 2020 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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