rmoff's random ramblings
about talks

Remove windows line feed characters in vi

Published Mar 27, 2009 by in Unix at https://rmoff.net/2009/03/27/remove-windows-line-feed-characters-in-vi/

If you work with a file in Windows and Unix at some point you might end up with windows line feed characters in your Unix file. It’ll look like this:

one line of text ^M
next line ^M
and next line with more ^M

To remove the ^M character, load the file into vi on unix and enter as a line command the following:

:1,$s/^M//

but instead of typing ^M do Ctrl-V Ctrl-M to get the charaters

Alternatively, load the file in Windows into Notepad++ and use Format -> Convert to UNIX format, then FTP the file back to Unix


Robin Moffatt

Robin Moffatt works on the DevRel team at Confluent. He likes writing about himself in the third person, eating good breakfasts, and drinking good beer.

Story logo

© 2025