Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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


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.