Search code examples
vimrecovery

How to dump the buffers in Vim on disk, after the files are destroyed


This might well be the dumbest post on SO but I really need your help.

Instead of rm -rfv build/., I rm -rfv build/../. At the moment, Vim is running, and it had been launched with vim *.h *.cpp. How can I save the in-RAM loaded files on disk?

What should one do in such a situation? :wa didn't help as "the files don't exist". update neither.

As far as why there's no git, in hindsight, no idea, but I've been taught that only solid, production quality code goes in Git and this code was rather embarrassing. Still, there is an old backup of the codebase on a hard drive, about a week's worth of work old.

Small update: Vim says `no swap file exists" for most of the files. Is this an incorrect setup? KDevelop e.g. would pop up a dialog and offer to re-save the files. Now Vim appears not so safe to me, enough to reconsider using it.

So to recap there are 2 questions here:

  1. Is it possible to recover the files from RAM in a situation like this? (Does Vim store all the opened files in RAM?)

  2. Is it possible to set up Vim so that it would behave like e.g. KDevelop, and offer or just make it possible to manually save a moved file back to where it used to be?


Solution

  • The FDinoff comment is probably the answer you are looking for. Re-create the directory structure and do :wa to save all buffers.