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?"
swp is a swap file, containing the unsaved changes. While editing a file, you can see which swap file is being used by entering :sw . The location of this file is set with directory option. The default value is .,~/tmp,/var/tmp,/tmp .
A swap file is a system file that creates temporary storage space on a solid-state drive or hard disk when the system runs low on memory. The file swaps a section of RAM storage from an idle program and frees up memory for other programs.
In .vimrc
add:
set shortmess+=A
From the docs :help shortmess
:
A don't give the "ATTENTION" message when an existing swap file is found.
There is plugin that can "Just do the right thing" automatically for Vim swapfiles: vim-autoswap.
From the homepage:
Dealing with swap files is annoying. Most of the time you have to deal with a swap file because you either have the same file open in another window or it is a swap file left there by a previous crash.
This plugin does for you what you would do in these cases:
- Is file already open in another Vim session in some other window?
- If so, swap to the window where we are editing that file.
- Otherwise, if swapfile is older than file itself, just get rid of it.
- Otherwise, open file read-only so we can have a look at it and may save it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With