Or you could skip step one, and only add percent signs on the lines
with anything in them:

(select lines visually)
:'<,'>s/^\(.\)/% \1

-Dmitriy

On 11/15/06, A.J.Mechelynck <[EMAIL PROTECTED]> wrote:
Meino Christian Cramer wrote:
> Hi,
>
>  a question more driven by curiosity than by the need to change
>  anything.
>
>
>  Suppose you have the following TeX-text:
>
>     bla blabla foo bar gnu gnats bla blabla foo bar gnu gnats bla blabla
>     foo bar gnu gnats
>     bla blabla foo bar gnu gnats
>
>     bla blabla foo bar gnu gnats bla blabla foo bar gnu gnats bla blabla
>     foo bar gnu gnats
>
>     bla blabla foo bar gnu gnats
>
>
>  and because this text is so fullfilled with wisdom and knowledge,
>  that no one else than you will be able to handle its contents
>  carefully ;) you decide to comment it out to not to harm the public.
>  As a vim newbie I would do that using block oriented visual mode on
>  the first line and I-nserting a '%' (TeX's comment sign), which
>  results in:
>
>  %  bla blabla foo bar gnu gnats bla blabla foo bar gnu gnats bla blabla
>  %  foo bar gnu gnats
>  %  bla blabla foo bar gnu gnats
>  %
>  %  bla blabla foo bar gnu gnats bla blabla foo bar gnu gnats bla blabla
>  %  foo bar gnu gnats
>  %
>  %  bla blabla foo bar gnu gnats
>
>
>  So far so nice...it works.
>
>  But would be there a way to acchieve the following commenting:
>
>  %  bla blabla foo bar gnu gnats bla blabla foo bar gnu gnats bla blabla
>  %  foo bar gnu gnats
>  %  bla blabla foo bar gnu gnats
>
>  %  bla blabla foo bar gnu gnats bla blabla foo bar gnu gnats bla blabla
>  %  foo bar gnu gnats
>
>  %  bla blabla foo bar gnu gnats
>
>  (blank lines not commented out) by a similiar simple command like
>  CTRL-v SHIFT-i <text><ESC> ?
>
>  As said: This Q is mostly curiosity - based...I even dont know,
>  whether haveing such a feature would be really useful or not.
>
>  But as always: Experimenting is fun! :O)
>
>  Keep editing!
>  mcc
>
>

1. Add all percent signs like you did above, even before blank lines.
2. Replace empty comments by blank (i.e. empty) lines as follows:

        :%s/^%\s*$//


Best regards,
Tony.

Reply via email to