Vim Removing “^M” Returns from Files

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.

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *