Vim Removing “^M” Returns from Files

By: Zhiqiang Ma In: Linux

When editing some files fro Windows in vim, there are some ugly “^M” returns. Here is a method to remove and replace these “^M”s (please note that you should not copy/past to use the follows):

:1,$s/{Ctrl+V}{Ctrl+M}//{Enter}

{Ctrl+V} means keyboard operation that is push ‘ctrl’ and ‘v’ together. {Enter} is push ‘enter’.

: means that it is a ex command.

1,$ means that the line number range is from the first line to the last line.

{Ctrl+V}{Ctrl+M} is the “^M”. {Ctrl+V} tells the vim to treat the next character as regular character.

Author: Zhiqiang Ma Last updated on: Dec 20, 2011 Posted on: Jan 6, 2010 Views: 312
Tags: ,
Like this post? Subscribe full-text feeds from all Fclose.com blogs:
Add your comments, share your thoughts

Be nice. Keep it clean. Stay on topic. No spam.