I have a file that's failing due to a single carriage return at the end (0x0D). It was originally a carriage return/new line combination (0x0D, 0x0A). I've tried:
- deleting it in INSERT mode (deletes the last printing character and leaves the carriage return)
%s/\r//(E486: Pattern not found: \r)%s/^M//(Ctrl+V, Ctrl+M to get^M) (E486: Pattern not found: ^M)Jto join with the next line (appears to do nothing to the last line)
All of them leave the carriage return in place.
How can I get rid of this character from within vi (not vim)?
EDIT
Now it appears it's adding a new line character (0x0A) whenever I save the file. So, the 0x0D is gone, but I still have an invalid character at the end of my file.
I tried adding two blank lines to see if it would add 0x0A or 0x0D, 0x0A (I'm using PuTTY from Windows) and it added two 0x0A characters, for a total of three.
If you have three lines, shouldn't you only need two line separators?
%s/\n//(no error, but doesn't remove the character)