Is it possible to retrieve changes branch that I "abandoned"?

For example, I am undoing several operations using u, then I am making a change in insert mode. But then I realize I don't want to have this change, I would rather go back to where I was at the beginning (before undoing).

Are these changes lost forever?

3 Answers 3


For navigating the undo tree your best bet is to use the Gundo plugin. This creates a new split window with special bindings to jump to different branches within the undo tree as well as a preview pane that shows you exactly what changed between each node in the tree.

  • 1
    Another choice would be UndoTree.
    – musicmatze
    Commented Feb 4, 2015 at 0:28

For simple cases like this, you can simply press g-.

Essentially, what this does is traverse the change list chronologically (treating a u as an actual change), rather than linearly (like with u/<C-r>).

For example, if you've inserted a few lines, and you press g-, this happens:


  • how did you create the animated gif?
    – guido
    Commented Feb 3, 2015 at 22:32
  • 4
    @guido I used a custom tool called mkcast.
    – Doorknob
    Commented Feb 3, 2015 at 22:34

No, you cannot go back and forward in the tree. The best way is to use a plugin to this job.

Another plugin is the Undotree. It's like Gundo, but with some differences:

  1. Pure vimscript implementation and no 3rd-party libraries(like python) is needed, don't worry about performance, it's not such a big deal for vim to handle this. The only dependency is the 'diff' tool which always shipped with vim and even without 'diff' you still can use most of the features of this script.
  2. Realtime updated undo tree. Once you make changes, the undo tree will be updated simultaneously.
  3. Several useful marks, like current changeset, next redo changeset, saved changeset, etc.
  4. Toggle between relative timestamp and absolute timestamp.
  5. Realtime updated undo window.
  6. Ability to clear undo history.
  7. More customizable.
  • 4
    Isn't this answer directly disproven by doorknob's post?
    – Caleb
    Commented Feb 4, 2015 at 9:00

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.