Alexei Alexandrov schrieb: > Hi, > > I'd like to request a feature in Vim which would be useful not very often but > is very important I think. > > Usually I don't lose information in Vim. You can undo things, you can restore > the file from a backup etc. There is only one situation which led me to > information loss several times. This situation happens when I have a file > with > modifications opened in Vim and then I also change this file by accident > outside of Vim. In this case Vim shows a message box with 2 buttons: reload > file or don't reload file. Several times I pressed "reload file" by accident. > And my changes in Vim were lost! Undo didn't work after that. > > I don't know if it's difficult to implement but it would be great if undo > worked after such reload. And this would be useful not only for "by accident" > cases - I could also press "reload" just to see what those external changes > are > and then undo if I don't need them. > > P.S. Persistent undo would be great too. :)
You can try a workaround with :h DiffOrig :h FileChangedShell au FileChangedShell * call DiffSync() func! DiffSync() " :DiffOrig vert new set buftype=nofile read # 0delete _ diffthis wincmd p diffthis wincmd p %diffput close diffoff endfunc Diffing against the changed file on disk adds the changes to the undo history. When writing the file you'll get a WARNING: The file has been changed since reading it!!! of course -- the function does not reload the file. As :h FileChangedShell states: | NOTE: The commands must not change the current | buffer, jump to another buffer or delete a | buffer. *E246* Trying the function I didn't get any errors though. -- Andy --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---