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