4

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+.

  • 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 Jul 2 at 7:55
8

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.

| improve this answer | |
  • wow, that really clears things up. I didn't realize they were distinct lists! – johnbakers Jul 2 at 12:33

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.