Removing DOS ^M from unix files
We have all had it happen. You get a text file from another user using Windows or even Mac. You open it up and the file looks trashed. This usually occurs when the file format of the file is unix but the content still includes the DOS Carriage Return / Line feed that show up as ^M in vim.
The simplest way to remove these annoying meta characters is using the col program.
cat file | col -b > newfile
However, today I ran into a file that was truncating on cat for no apparent reason. So, I had to do the edits in vim. This is mainly to remind myself because I wind up looking this up every time I need it.
In vim to replace DOS CR/LF with a unix newline type:
:%s/CTRL-V+M/CTRL-V+ENTER/g
Looks like:
:%s/^M/^M/g


