A web developer’s diary

October 28, 2006

^M problem in Editors

Filed under: Vim — Celia @ 9:27 am

If you are one of those kinds who shuttle between environments like windows/linux/mac, you would have come across this problem many a times.

You would have just received a file from one of your mac friend and when you open it, you would see the file being elegantly decorated by the ^M character at the end of each line.

Well, its not really the ^M character. This happens when the editors can’t interpret the linefeed characters properly. But we can’t keep living with this character. Can we? But how to replace this to null in the file?

Try out this simple command in the command mode.

:%s/^M$//g

Note: The ^M is not carot M. It is CTRL V CTRL M.

Advertisements

1 Comment »

  1. I think, :%s/^M//g is enough.
    to ask for confirmation, use :%s/^M//gc

    Comment by rajaram — December 5, 2006 @ 6:24 pm | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: