Removing silly Windows cruft from perfectly good text files

Having Linux be my primary desktop environment is not without it’s challenges working in a large corporation of primarily Windows users, but when this even gets into how I have to treat text files I put my proverbial foot down!

When you see those nasty little ^M characters sneak into your party you can kick them out, a couple quick searches and you will probably find this or a similar global substitution pattern[1] that you can use inside Vim or gVim:

[code]
:%s/^M//g
[/code]

Just beware this is a control character so you really need to type:

[code]
:%s/{Ctrl+v}{Ctrl+m}//g
[/code]

Footnotes    (↵ returns to text)
  1. Removing carriage returns from MS-DOS file- http://www.oualline.com/vim-cook.html#eol

Leave a Comment