Vim remove ^M

I’m always needing to remove ^Ms in vim and forgetting the command - heres the details:

The stuff to type in

:%s/ctrlkey+v then ctrlkey+M//g

What appears in the vim command line

:%s/^V^M//g

Note:

  • ^Ms appear in your files after edits in Windows
  • In the comments on Google+ Kae has pointed out that you can just enter %s/ctrlkey+v then enter//g to remove the ^Ms as well

Justin Kelly

Justin Kelly

Data Engineeer, Business Analytics, Web Developer, Library Technology specialising in PHP and Tableau

Based in Melbourne, Australia

Feel free to contact me justin@kelly.org.au or _justin_kelly