use vi editor to insert newline char in replace
April 28, 2009 2 Comments
Something else I have to do and cannot remember and then have to look up.
In vi to insert a newline character in a search and replace, do the following:
:%s/look_for/replace_with^M/g
the command above would replace all instances of “look_for” with “replace_with\n” (with \n meaning newline)
to get the “^M”, enter the key combination “ctl-V” then after that (release all keys) press the “enter” key.
thanks. You beat stackexchange…. 😉
Yours worked. (I could never remember how to do control-capital-V thing.
Glad it helped. Was always killing me too. I had to write about it.