I ran across this simple plugin which automatically deletes the swapfile if it contains no differences:
Can you implement similar functionality in your plugin?
Thanks. I look into it.
Please try the current version.This is an experimental version, but seems to do what you like.
Nice. Further thoughts- when opening the same file from two different vim processes, I would not let the second vim process recover from and delete the swapfile if the first instance is still running. Also would it be possible to allow the user the diff option in addition to the original list of options? I frequently want to abort or quit, especially if the swap file is the result of another running vim instance.
Yes, that is exactly the problem, why I am unsure about deleting swap files. As far as I know, there is no possibility, to know from within Vim whether a different Vim session is editing the same file. (May be, this feature needs a patch to the Vim source) I need to think about a workaround.
The other options should be possible as well.
The swap file does indicate the process id, so it could be possible to check if that process were still alive and if it was named vim. But i'm not sure if that could be done in a portable way.
I know. But I think, Vim does not make this information available through its interface. You basically only know, whenever Vim shows its recovery dialog. That's what I mean when I said Vim needs a patch.
How about, we install an extra autocommand, that checks, whether the swapfile still exists, and if not, recreates the swap file? Would that work until a better approach with Vim can be found?