This website recently got a major rebuild; if you're missing something, let Lorna know.

Cleaning up Windows Line Endings in Vim



I have a file which has been edited in windows with an incorrect setting. All the lines have


^M

At the end of each line.

To search for these in Vim, you can type ctrl+v (to mean “take my next key combination literally”) then ctrl+m. To clean up my file I used:


:% s/^M$//

Where the ^M is typed using Ctrl+V, Ctrl+M. I’ve recorded it as a macro as I seem to be fixing the same thing a lot these days. Hope that helps someone!


In: tech