No eol in swap file

I was editing a file with vi and crashed so when I opened the file again I had the .swp file to deal with. I made the wrong choice trying to recover my file and wound up with a file with no eol (end of line) characters.

I have forgotten the code to substitute and don't want to make an even bigger mess. What I see now are thousands of ^@ characters.

After I thought I had recovered the file I gave the command
mv .[filename].swp [filename]

The .file.swp file is the editing state file for vi (or vim) for the file named file. If vi died or our system died while you were editing the file, the way to recover your file is to execute the following commands:

# create a back up in case recovery fails
cp file _file

# load the latest saved state of the file from the swap file and write it into file
vi -r file
:w
:q

You can then compare file and _file to see if you got the version you wanted. Then you should remove .file.swp before you edit the file again.

Since the swap file is a binary file (not a text file), you probably don't want to use the mv command you tried. If you haven't modified the file after moving the swap file to your original file name, you can move it back to its swap file name and then try the steps I outlined above.

Thank you!! That worked and all is back like it should be.