>>> Sometimes even after I save my changes to a file using :w, I >>> can undo these changes (using u). But sometimes I cannot undo >>> after I have saved the file with :w. In both cases, I don't >>> close the file or exit vim. > >> - something (possibly a plugin) is reloading the buffer after >> it's been saved which would make vim treat it as a "new" file >> with no undo history. I'm not quite so sure how to check if this >> is happening, other than to scan through scripts (check the >> output of ":scriptnames" >> > > I think this is it. I didn't know that if we reload the buffer say > using :e, it loses all undo history. Sometimes I might do a :e! to > abandon all the latest changes and revert back to the last saved copy > of the file, and then when I go back to that last saved copy, I > realize that I still need to do a few more undos. But now undo doesn't > work since I have already reloaded the buffer using :e!. Is it > possible to keep the undo history across several loads of the same > file (especially when I'm not explicitly closing the buffer with a :q > like in this case)?
I don't think it's natively possible, but it might be mappable/hackable...something like :%d :r % :1d which (1) deletes all the content, (2) reads in the content from disk below the one blank line remaining, and then (3) deletes the spurious blank line. The above could be wrapped in a function/command/mapping and then used in place of ":e!" to "reload" the file in the same setup. Your undo should then walk back beyond this "reload". -tim --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
