I saved and closed a file I was editing. When I opened it again a minute later, vim gave the warning that appears when a .swp file is present. I selected the recover option, but the "recovered" file did not have any of my recent work. Then I checked the dates. Somehow, the .swp file was last changed two months ago. Two questions: How could a .swp file suddenly appear from so long ago? I have been regularly editing that file ever since, and this is the first time that has appeared. More importantly, is there any way I can recover the version that existed a few minutes ago?

  • For future reference to people browsing this question: Here's the accepted answer. Nov 2 '16 at 10:58
  • Please add your link to an answer so this can be marked completed.
    – jecxjo
    Nov 2 '16 at 16:19

Solution: search partition for fragments of the file using strings, then pass the returned offset to dd as described here: https://unix.stackexchange.com/a/320150/176250

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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