Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

2 Answers 2

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
done

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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.