3 ms·
> only to discover the diff is literally null. Note that you can save the trouble of running diff by watching for the message "Buffer contents equals file cont
by lucb1e 6y ago
> only to discover the diff is literally null.
Note that you can save the trouble of running diff by watching for the message "Buffer contents equals file contents." Only when they're different, you'll want to write the file to another place and diff it.
What bugs me a lot is that, even if the contents are equal, it doesn't cleanup the swap file... is there maybe a command for that so I don't have to go back to my terminal, manually remove .<filename>.swp, and open up vim again?
- lloeki 6y agoI don’t think you even need to write, I have this shortcut[0]: nmap <leader>d :w !diff -u % -<CR> It writes the buffer’s content to diff’s stdin, and diff gets passed the filename (hence the current on disk content) to compare vs stdin (hence the current buffer content). Only I wish it were run automatically by vim in aforementioned cases before whining (case a: recover, run the above, if no diff stop complaining; case b: rewind til last save, run the above, if no diff then replay and save without complaining) [0]: https://github.com/lloeki/vimfiles/blob/9c50f3be60e536518beb5d80637691c2207bf1ab/vimrc#L124 https://github.com/lloeki/vimfiles/blob/9c50f3be60e536518beb...