I have this perl regex:
s/(^(#+)\s.*?\g2)/$1 =~ s|\n| |rg/gmse
It strips out all new lines between ##+
characters and replaces them with a space. It'll take a string like:
before text
more text
### hjh jh ja jhjasdhf jh'j
asdk kas dkjakdjf kasjd fkjasdkfj
kajsdkjf kasjdf end ###
after text
and change it to:
before text
more text
### hjh jh ja jhjasdhf jh'j asdk kas dkjakdjf kasjd fkjasdkfj kajsdkjf kasjdf end ###
after text
I want to do the same with vim. I discovered I can use \=
to turn the right hand side into an expression, but how do I perform a substitution on the value of \1 and print it out?
%s/\v(^(#+)\s.*?\g2)/\= WHAT GOES HERE?/g
:h submatch()
:perldo ...
might be faster to do it the perl way