8

When I open another file in a Vim session all editing history for the other files disappears.

Is it possible to configure Vim that it would automatically save and restore file editing history when hopping through files?

3
  • gvim and vim are the same program. Just the UI is different. Feb 4, 2015 at 10:16
  • @Carpetsmoker Yes you are right, I'll update the question.
    – niekas
    Feb 4, 2015 at 10:20
  • 1
    Voted to reopen because, as I read the question, the OP isn’t closing Vim, merely switching files within it. ’undofile’ isn’t required to fix this: setting 'hidden' will suffice.
    – Rich
    Jul 12, 2018 at 5:34

1 Answer 1

11

What I do is add the following to my .vimrc:

set undofile
set undodir=~/.vim/undo/

That way all your undo/change tree information is saved across vim sessions, and next time you open your file you can still undo/redo old edits.

1
  • 2
    You also need to mkdir ~/.vim/undo. Vim won't autocreate it.
    – Tobu
    Mar 12, 2019 at 18:49

Your Answer

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

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