Sunday, June 29, 2008

Difference of "change line mark" between windows and unix

In unix, line ends with a new line charactor, i.e. 0x0a.

In DOS/Windows line ends with a carriage return and new line pair, i.e.
0x0d0a.

In your case, every line ended with a carriage return, i.e. 0x0d, which is
displayed as '^M' in vi.

You need to replace every '^M' to new line in vi with the following command:

:%s/^M/\r/g

Note: ^M is entered as pressing 'v' and 'm' while holding 'Ctrl'.

OR :%s:\r:\r:g

No comments: