Friday, November 21, 2008

Windows new line in vi

To have windows new line in vi, use
CTRL+v, then enter

2 comments:

Gireesh said...

can you explain the scenario...

If we create files in windows and copied to linux boxes, we can see some ^M characters.. These are normally the new line character. We can remove these characters using the utility, dos2unix command. Or in vi editor, we can do a search and replace, as follows:
:%s/^M//g

Remember, the ^M is nothing but the combination of 'ctrl+alt+M' and NOT shift+6+M

Diju Pavithran said...

Just as u mentioned, ^M can be obtined by 'ctrl+v + enter', also.

I had to export some values which was in csv format. I needed to get those in values in separate lines, in windows. Instead of opening it in MS-Word or application like that, i opened that i gvim, and gave a search/replace
:%s/,/^M/g
^M - 'crtl+v enter'