vimConverting text files from DOS to UNIX with vi


Remarks

The ^M character stands for a carriage return in Vim (<c-m> or just <CR>). Vim displays this character when at least on line in the file uses LF line endings. In other words, when Vim consider a file to have fileformat=unix but some lines do have carriage returns (CR), the carriage returns are displayed as ^M.

A file that has a single line with LF line ending and several lines with CRLF line endings is most often created by wrongly editing a file created on a MSDOS based system. For example, by creating a file under an MSDOS operating system, copying it to a UNIX based system, and then prepending a hash-bang sting (e.g. #!/bin/sh) using tools on the UNIX based operating system.