Archive for September, 2012

h1

Setting all line endings in a DOS file to UNIX

September 13, 2012

If you have a nasty DOS file and you wish to convert the it from any mixture of CRLF/LF-only line endings, so all lines end with LF only:

Save any changes.
:w

Edit file again, using dos file format (‘fileformats’ is ignored).
:e ++ff=dos

This buffer will use LF-only line endings when written.
:setlocal ff=unix

Write buffer using unix (LF-only) line endings.
:w