Vim: Replacing ^M with a new line

SEOPublished March 12, 2010 at 1:11 pm 2 Comments

I recently uploaded some new software for a domain I utilize – and of course the dreaded newline replacements (^M) are all over the place. To fix this – I type one simple line:

For Mac Users in VIM or VI:
%s/\r//g

For windows users in VIM or VI:
%s/[cntrl+m]//g

This will replace them throughout the file. Happy Coding!

2 Comments to “Vim: Replacing ^M with a new line”
  1. BiffSocko says:

    you can use the dos2unix command to get rid of the ^M.

  2. BiffSocko says:

    I should have mentioned the syntax; you can do:

    dos2unix filename filename

    this makes the conversion and puts the changes back into the same file.

Leave a Reply

(required)

(required)