Skip to content

How to Fix ^M Characters in Vim

I opened a CSV file in Microsoft Excel. I approved compatibility with macros on a Mac. Then, I opened the same CSV file with vim.

The entire CSV file was reduced to a single line whenever I opened the file with vim.

Something like this:

Number of Sloths,Type^M15,black^M10,brown^M5,blue

Example of the ^M character on every line in vim.

If we try to substitute all the ^M characters, those characters aren’t found!

vim slothparadise.csv

The characters are actually a little different. We use vim‘s substitution for \r.


All the ^M characters should be exchanged to be proper new lines.