Powered by Blogger.

Tuesday, January 12, 2010

Tag: , , , , ,

VIM how to remove ^M at the end of lines

In unix the end of line is different than other systems. More times we edit windows files and when open in VI/VIM we see the ^M character at end of lines.

We can remove this characters with a simply search and replace of vim with this command:

The ^M character is not valid write first ^ character and then M it's not the valid character. To write correctly this we must push Control+v and Contro+M keys, then appear our ^M Character.

Take care with this.

About David Millán Escrivá

David completed his studies in Universidad Politecnica de Valencia in IT with a Master's degree in artificial intelligence, computer graphics, and pattern recognition, focusing on pattern recognition and Computer Vision. David has more than 15 years of experience in IT, with more than ten years of experience in Computer Vision, computer graphics, and pattern recognition, working on different projects and start-ups, applying his knowledge of Computer Vision, optical character recognition, and augmented reality. Co-Author of two OpenCV books and reviewer of few more.


  1. May I also sugest dos2unix: http://linux.about.com/od/commands/l/blcmdl1_dos2uni.htm

    Its a linux command that does what you are having to do with vim in this case, which is change the ending of lines fro windows type to unix.

    Can be a lifesaver on large files or C projects that you send to linux via winscp o samba.

    Kind regards,

    David Lisin