Tuesday, April 20, 2010

newlines/escaping in regexes in vi

Regexes in vi make me sad sometimes. I discovered today that when I wanted to replace all instances of:
||
with:
|
|
the correct command wasn't
:%s/\|\|/\|\n\|/g
but rather:
:%s/||/|<ctrl-v><ctrl-m>|/g
... where <ctrl-v> literally means "hit ctrl-v".

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.