I tried opening the .swp file using
cat but it displays junk.
You don't need to have to original file to recover the .swp. Just open the file as if it exists. vim will look for the file with the .swp extension and offer to recover it.
Just press r for recover and :wq the file
Edit: Note that the .swp file only contains the changes done to the file (see comment). This means that you will need to fetch a recent copy of the file from backup and then use vim to recover the latest changes. If you don't have a backup copy of the file your really out of luck.
This goes into recovery mode and gives you more info. I think this is what you want.
After I read Vegar Westerlund and Heptite comments, I wanted to know at what point vim needs the original file (or a backup) to recover from a .swp file. Here's what did:
I opened a 975 lines file, edited it on line 949 (creating a
I repeated that with smaller files: from 20 up to 200 lines, the .swp file contained 100% of the original content. But at 300 lines, only the first 68 and the 18 last lines (starting 2 lines above my edit) were included in the .swp.
As a conclusion it's good to know vim always save the file's "header" in its .swp files. Also, maybe there's a setting to control how much lines should a .swp contains.