1

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?

iksemyonov
  • 4,106
  • 1
  • 22
  • 42
  • You might need to recreate the directory structure. And then `:wa` should hopefully work. – FDinoff Feb 25 '16 at 18:56
  • Have a look at http://vimdoc.sourceforge.net/htmldoc/usr_11.html#11.1 or check the `~/.vim` directory for any automatic backup files. – Leventix Feb 25 '16 at 19:08
  • "Vim appears not so safe to me" – it's not really vim's job to back up your stuff – Leventix Feb 25 '16 at 19:10
  • @Leventix in a sense I agree, but why does KDevelop then offer to re-save the open file of it's moved? Isn't that logical? Same thing as Word etc. create backup files and protect your data to a certain extent. Nope ~/.vim is empty unfortunately :( – iksemyonov Feb 25 '16 at 19:15
  • By default swap files live next to the original file. But you deleted those too. – FDinoff Feb 25 '16 at 19:34
  • Even if you were in git, that rm command probably would have deleted the git repo. Most of the time I see build living in the same directory as .git. – FDinoff Feb 25 '16 at 19:35
  • @FDinoff well with git I could have had a version more recent that the one I have now. Comment about where swap lives is valuable indeed, note taken. – iksemyonov Feb 25 '16 at 19:42

1 Answers1

1

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

Mad Wombat
  • 14,490
  • 14
  • 73
  • 109
  • Combine `:wa` with the following post: [Vim: Creating parent directories on save](http://stackoverflow.com/q/4292733/438329) – Peter Rincker Feb 25 '16 at 22:14