What’s the easiest way to delete Vim swapfiles I’ve already recovered from


Sometimes Vim crashes and leaves me a swapfile. That's awesome. Then I open the file I was editing and Vim asks me if I want to recover. I do, thanks. When it's done, Vim tells me,

You may want to delete the .swp file now.

Why, yes, I do. How do I do that? I figured it would just start using the old swapfile as a swapfile again and clean it up when I quit, but that's not true. It makes a new one, cleans that one up, and when I open the file again it prompts me again to recover from the first one.

Surely I'm missing something.

Best Answer

A slightly simpler way:

From the terminal emulator:

vim filename

Then choose recover, and if you want to delete the swap you write (save) and then do this from within vim:

:e          // no argument needed. It assumes the current buffer.

...and choose delete this time.

I just found out about this, and I think I'll do that from now on. Then I won't accidentally overwrite a working file either, if the recovery turned out corrupt (though I've never tried that before).

There are also relevant tips on this question on Stack Overflow (where I found this tip).