Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Multi-line comments in perl code?

by doom (Deacon)
on Jul 17, 2006 at 23:05 UTC ( [id://561884]=note: print w/replies, xml ) Need Help??


in reply to Re: Multi-line comments in perl code?
in thread Multi-line comments in perl code?

Emacs also has a "ESC x comment-region" command (which I have bound to a key, myself). Select the block of multi-line text, do a comment-region, and in cperl-mode, "# " will magically appear in front of every line. If you do a "C-u" prefix first, you can use the same command to remove the commenting.

Alternately, it's not at all difficult to write keystroke macros that do things like "insert a '#' in front of this line and then move down one line", which you can loop to comment a series of lines.

The default keystrokes for that (Off the top of my head, and untested):

Defining the macro:

C-x ( C-a # C-n C-x )
Running it once:

C-x e
Running it 10 times:

C-u 10 C-x e

My personal preference: don't use one of the workarounds. Everyone understands "#" commented lines, but many will find your workaround confusing. Optimize for readability, not for ease of typing.

But if you do use a workaround, my preference would be for abusing pod ('=for comment/=cut'), which is endorsed by Damien Conway in "Perl Best Practices".

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://561884]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-24 02:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found