3 ms·
> I don't think the problem is actually swap files themselves, though, but the user experience with them. Agreed, the UX is 99% the reason of me hating swap fi
by lloeki 6y ago
> I don't think the problem is actually swap files themselves, though, but the user experience with them.
Agreed, the UX is 99% the reason of me hating swap files. More often than not I choose recover, only to discover the diff is literally null. Come on, you could not check for that before interrupting? And then in any case you have double the annoyance with that recovered buffer as the old swap remains and you have to delete it or you get the warning again on the next open.
It’s kind of like changing branches with git and then back again, vim notices the time stamp of an opened file changed vs the last buffer save, lets you change the file but complains on :w that the file “changed” outside, yet is unable to a) show you a diff of current buffer vs current file, nor b) realised that the filesystem state vs buffer state at last save (which vim fully knows about) produces a null diff, so the buffer changes are safe to write.
- 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...