Vim: Stop "existing swap file" warnings

Viewed 33023

I have no idea why, but it seems that no matter how I quit out of Vim, it always leaves the swap files behind. So, whenever I open that file again, I get an irritating error about an existing swap file. Every time I have to choose "delete". I really wish this would stop. Is there anything I can put in my .vimrc to tell it, "just delete the swap file if it exists and leave me alone?"

8 Answers

Command-Q on the Mac OS quits the Terminal window, and crashes every application running in the window.

To quit VIM, you have to use ordinary VIM commands like :q.

See the VIM recovery manual entry. You shouldn't be seeing these files normally, unless

  1. your VIM instance is crashing
  2. you're inadvertently running two VIM instances against the same file

I quite often do the latter, running 2 VIMs against the same file, in two terminals, without realising it. The 'swap file' message is the indicator that I'm doing this.

Perhaps you've got a VIM session running (backgrounded?) that you've forgotten about ?

It's possible that you have not enough rights for some directory in the path to your current directory. It just happened to me.

Related