I use MacVim (snapshot 51)
to edit a the Python/HTML/etc files in moderately sized project. Every few months my system locks up or crashes, and Vim leaves a plethora of .*.swp files around. When I go to re-open Vim after the crash and edit any of those files, I am told "Swap file ''.xyz.swp'' already exists!" with the options of [Abort] [Quit] [Delete it] [Recover] [Edit anyway] and [Open Read-Only].
This recovery option would make sense if there were changes to the Vim buffer that hadn't been saved at the time of the crash. However, at the time of the crash these files were opened in the background of Vim, and unchanged.
If possible, how can I configure Vim to not ask this superfluous question when opening files for which there are no changes between the .swp
file and the actual file, e.g. by one of:
-
Automatically comparing the changes in the .swp file to the file, and if there are no changes then just opening the file without prompting;
-
Not keeping a .swp file for files that have no changes.
-
Any other means of systematically avoiding this pointless prompt (but I'd prefer not to avoid the prompt in cases where, of course, there were unsaved changes).
I have over fifty .swp
files to clean up at the moment, and the pointless prompt is a frustration I'd be grateful to avoid.
Thank you for reading.
Brian
Best Answer
I haven't tested it, but what about this solution presented in vim's official wiki?
Swap file "..." already exists! - so diff it
There's a script for this problem as well in Stackoverflow.