I'm not a VI or Perl expert, but I seem to remember someone saying you could embed Perl in VI. If so, I'm guessing you could attach Perl scripts to a custom command. If that's the case, create two commands. Attach one to a script that adds block comments and the other to a script that removes them. Define your C-style comment delimiters (not /* */, since they tend to come up often in regex), then run the block comment script on the current file.

The script runs through your file looking for a start comment delimiter. When it finds one, it puts a '#' in front of it, then one at the start of each subsequent line until an end comment delimiter is found. The remove block comment script does the opposite.

There are a few other issues to solve, such as having an end delimiter in the middle of a line of code, or a line of code that was already commented before you ran the block comment script, but there are ways around these issues.

I just made this up this morning. It's still too early for me to tell if this is a good idea or just something really silly. :-)

Phemur


In reply to Re: Perl equivalent of C-style by Phemur
in thread Perl equivalent of C-style by wattk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.