7

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?

  • gvim and vim are the same program. Just the UI is different. – Martin Tournoij Feb 4 '15 at 10:16
  • @Carpetsmoker Yes you are right, I'll update the question. – niekas Feb 4 '15 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 '18 at 5:34
8

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
    You also need to mkdir ~/.vim/undo. Vim won't autocreate it. – Tobu Mar 12 '19 at 18:49

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.