Remove ^M in Vim

016th Feb 2010Systems Administration, ,

Often people upload plain text files to one of the sites that I work with and when I edit it through Vim it’s covered in ^M’s… They’re created by Windows clients because there operating system deals with the end of a line differently to Linux.

To remove this in Vim

:%s/^V^M//g

The ^v is a CONTROL-V character and ^m is a CONTROL-M. When you type this, it will look like this:

:%s/^M//g

No Comments Comments Feed

Add a Comment

*

Spam protection by WP Captcha-Free