Saturday, March 03, 2007

ADD new line in VI

After much searching and even reading bits of the manual... I give up... I want to do this:

:%s/pattern/\npattern/g

Where \n will start a new line... I'd really thought this would work but I get ^@ instead... any ideas how to do this properly?

ANSWER:

I found a work around.. (possibly the correct way... but I doubt it)

when building the string in Gvim - hit ctrl+v then tap return (enter) [sometimes it's ctrl+v and tap m: ctrl+v+m] this pastes in a ^M which is actually a newline character. Worked for me.

:%s/\\n/(@ctrl+v+enter@)/g

0 Comments:

Post a Comment

<< Home