I've been trying to write a regex that turns the following structure
# Ignore this line
Foo
Foo
# Ignore this line too
into:
# Ignore this line
IF BAR THEN
Foo
Foo
# Ignore this line too
So far I have the following regex:
%s#\(\n\)\?\(\(Foo\n\)\+\)\(\n\)\?#\= submatch(1) . 'IF BAR THEN\r' .
substitute(submatch(2), 'Foo', ' &', 'g') . submatch(4)#gc
Which gives me:
# Ignore this line
IF BAR THEN\r FOO
Foo
# Ignore this line
I have tried using \n
, <CR>
, ^M
but none seem to have the desired output. Please advise!