If I'm working in a file, change to another buffer, and then change back, I have lost my undo history.
vim File1.txt
- make a bunch of changes & save.:e test.txt
:b#
Any workarounds for this?
You could :set hidden
. This means that the buffer of the old file will only be hidden when you switch to the new file. When you switch back, you still have your undo history.
You can also add persistent undo, this will have vim store your undo even through restart:
" Persistent undo
set undofile
set undodir=$HOME/.vim/undo
set undolevels=1000
set undoreload=10000
Edit - via @sanbor:
Don't forget to do mkdir ~/.vim/undo
, otherwise vim won't do it for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With