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?"
views:
832answers:
5
+5
A:
See the VIM recovery manual entry. You shouldn't be seeing these files normally, unless
- your VIM instance is crashing
- 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 ?
Brian Agnew
2009-07-08 13:45:22
Isn't a swap file different for a backup file? You leave a swap file around if vim crashed before closing the buffer properly.
nik
2009-07-08 13:53:35
So I've just launched 'vi Test.java', then background-ed it. Then I launch another 'vi Test.java'. And I get "Swap file .Test.java.swp already exists", which makes sense, I think
Brian Agnew
2009-07-08 13:57:52
The swap file is created when opening a document in vim and deleted when the document is closed properly.
Corban Brook
2009-07-08 14:14:13
@Nik - my original answer referred to backup files. Is that what you're commenting about ?
Brian Agnew
2009-07-08 14:16:35
+10
A:
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
.
S.Lott
2009-07-08 15:07:51
A:
Put this in your vimrc file.
if has("win32") || has("win64")
set directory=$TMP
else
set directory=/tmp
end
Lolindrath
2009-10-14 17:08:23