[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: multi line regex's in vi ...



> So add <p> to any non-blank line?  I'd like to know a one-liner for this
> too.  You've got blank line with ^$ but how do you negate that?

but what if a paragraph has more then one line.  you have to detect the
beginning of a new paragraph and then insert a '<p> ' before the first line
of text.

> A two-liner is
> %s/^/<p>/   - add <p> to the start of each line
> %s/^<p>$//  - remove any lines that contain only <p>

nope won't work.  it'll put a '<p> ' at the beginning of every line which
has text in it.  thus this:

one lineladf aflkasd flaskdjf alskdfj alskdfja lskdjf alskdjf alsdkfj
lasdkfj alkjdfalskjdf laskdfj laskdjf laksdjf alksjf ald  lkadjflaksdjf

laklj and the end of aldkfja ladkfj alksdjf oqieruoqiewjrlkdmflk adlf ladfj
ladkf alkdjf lakd flaksdj flaksdfj.

will become this:

<p>one lineladf aflkasd flaskdjf alskdfj alskdfja lskdjf alskdjf alsdkfj
<p>lasdkfj alkjdfalskjdf laskdfj laskdjf laksdjf alksjf ald lkadjflaksdjf

<p>laklj and the end of aldkfja ladkfj alksdjf oqieruoqiewjrlkdmflk adlf
<p>ladfj ladkf alkdjf lakd flaksdj flaksdfj.

adam.


Reply to: