Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: Maintain the history of a file after it has been changed and reloaded

Tags:

vim

If I'm editing a file in Vim, then some external program changes the file, Vim tells me:

W11: Warning: File "test.erl" has changed since editing started
See ":help W11" for more info.
[O]K, (L)oad File: 

If I Load the file, though, all the undo history is lost.

Is there any way to avoid that?

like image 215
David Wolever Avatar asked Dec 17 '25 06:12

David Wolever


2 Answers

Update: it appears that this is one of the new features in Vim 7.3: https://groups.google.com/group/vim_announce/browse_thread/thread/66c02efd1523554b

like image 157
David Wolever Avatar answered Dec 20 '25 13:12

David Wolever


I don't believe this is possible.

There is a very useful patch available for the vim source code available here that keeps the undo history after exiting vim and restarting. However, I've just tried it and it seems to fail when the file is edited externally. It might be worth contacting the author or reporting a bug on the patch website to see if this can be overcome.

like image 38
DrAl Avatar answered Dec 20 '25 12:12

DrAl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!