Reputation: 229
I want to substitute the value of HTML <br>
tag with 2 newlines. i.e what i want to is
$string=~s/br>/\n\n/s;
but somehow it doesn't work. Whereas it works fine for a single new line. i.e. if i do this:
$string=~s/br>/\n/s;
it works fine. What am I doing wrong?
Upvotes: 0
Views: 296
Reputation: 40927
If you're talking about vim's substitute
command then you probably want to use \r
in the replacement string instead of \n
. In this context vim treats \n
as NULL, not newline.
Relevant snippet from :help sub-replace-special
:
<CR> split line in two at this point
(Type the <CR> as CTRL-V <Enter>) *s<CR>*
\r idem *s/\r*
\<CR> insert a carriage-return (CTRL-M)
(Type the <CR> as CTRL-V <Enter>) *s/\<CR>*
\n insert a <NL> (<NUL> in the file)
Upvotes: 1