Mac line endings and vi


See http://vim.wikia.com/wiki/Change_end-of-line_format_for_dos-mac-unix

If Vim believes that a file has unix format, any CR will display as ^M (because CR is Ctrl-M).

Vim supports three file formats: unix (lines end with LF), dos (lines end with CR LF), and mac (lines end with CR).

Some programs create files with inconsistent line endings. For example, the first few lines may end with LF, and Vim will decide the file has the unix file format. But later lines may use CR LF and Vim may show the CR as ^M.

To replace every CR with LF (when searching, \r matches CR, but when replacing, \r inserts LF):

:%s/\r/\r/g
line
linux logo Powered by Apache
line
This site maintained by:
lukas.zimmermann@unibas.ch
My public PGP key
last updated: 2007-01-24 Valid CSS! Valid XHTML 1.0 Strict