Such .swp files should never exist if you always exit Vim normally.
Only when Vim crashes or gets terminated abnormally will you have such files hanging around.
Having them stick around is how recovery works.
One of the "swap exists" choices that will appear the next time you edit that file, is to delete the swap file. If Vim is not editing that file, under what circumstances should Vim delete them? You risk losing the ability to recover files if Vim scans the current directory for any swap files on startup or something.
On Unix-like systems, swap files should be hidden by default, so you won't see them cluttering up anything unless you deliberately show swap files.
On Windows systems, check out my autohide plugin to accomplish the same:
Also there may be swap files associated with a DIFFERENT Vim instance, especially if you or others edit files on a network location using Vim from multiple computers.
Deleting them automatically might interfere with other Vim instances. I think you will always want a confirmation step at least before deleting swap files.
mike's suggestion is I similar to what I use... and it works quite well... I also prepend the abs path to the file to avoid name collisions...
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
--- You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
And if you pass the -d argument to the find method it will never match swp files :-)
set directory=$HOME/.vim/swap
find ~/.vim/swap -type f -atime +30 -name \*.sw? -exec rm -f {} \;