0

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?

Kyle Brandt
  • 83,619
  • 74
  • 305
  • 448

2 Answers2

1

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.

Cascabel
  • 288
  • 2
  • 9
1

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.

LapTop006
  • 6,496
  • 20
  • 26