Take the 2-minute tour ×

So, if I have a screen session with maybe 15 files open, in about 10 instances of VIM, and my landlord yanks my power ...

Can I load everything up and recover the swp files, and delete them after in an automated way. More importantly, is this not a smart thing to do for some reason?

share|improve this question
add comment

2 Answers

You can easily open them all up by doing something like

for swpfile in .*.swp; do
    swpfile="${swpfile#.}"    # strip the initial "."
    vim "${swpfile%.swp}"     # strip the extension

and doing whatever you like in Vim (probably a lot of (r)ecover enter enter :wq, I assume).

You can also do this from within Vim using the :recover command - write a quick script to list the files and call recover for each (you may even be able to silence the prompt) then save. I don't remember well enough to do it this way off the top of my head, though.

share|improve this answer
add comment

I'd be more concerned about lower level filesystem damage.

A basic UPS isn't that expensive and could give enough time for a clean shutdown.

share|improve this answer
add comment

Your Answer


