Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Convert Mac to Unix line endings in VI (See related posts)

If you open a text file in VI and see one big line with lots of '^M' where the line endings are supposed to be, use this command to fix it.
(Enter the the ^M by hitting ctrl-v and then the return key.)

:1,$s/^M/\r/g

Comments on this post

Araxia posts on Oct 14, 2007 at 22:54
FWIW, here is a slightly easier to remember version:

%s/\r/\r/g


%
is shorthand for 1,$, and as odd as it looks you can use
\r
for both sides of the substitution and it works. This way, you don't have to remember Control-V.

You need to create an account or log in to post comments to this site.


Related Posts