Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Multi-line comments in perl code?

by loris (Hermit)
on Jul 14, 2006 at 08:19 UTC ( [id://561170]=note: print w/replies, xml ) Need Help??


in reply to Multi-line comments in perl code?

Hello mrguy123,

With emacs you can do

# A long comment which I would rather have on multiple lines

and then do

M-x fill-paragraph

(which is often bound to M-q) to automagically get

# A long comment which I would rather # have on multiple lines

the position of the line break depending on the setting of the variable fill-column.

So spend a few days (months, years, ...) getting your head round emacs and (then) have fun.

loris


"It took Loris ten minutes to eat a satsuma . . . twenty minutes to get from one end of his branch to the other . . . and an hour to scratch his bottom. But Slow Loris didn't care. He had a secret . . ."

Replies are listed 'Best First'.
Re^2: Multi-line comments in perl code?
by BrowserUk (Patriarch) on Jul 14, 2006 at 08:34 UTC
    Does this car have a handbrake?

    No, but if you keep pressing the footbrake it won't go anywhere.

    But isn't there an easier way of stopping it from rolling away on inclines?

    Well. If you buy an 18-wheel semi-trailer truck, learn how to drive it with it's 10 gears & hi-lo ratio shifts, and arrange to park it wherever you want to stop in your car; then if you park your car uphill from it, it won't roll very far.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      C-u BrowserUk M-x detect-believer-in-the-one-true-editor No believer-in-the-one-true-editor 'BrowserUk' found (you can run this + command with 'C-g C-r C-o C-w M-n M-e M-w C-d C-i C-g C-i C-t)

      loris


      "It took Loris ten minutes to eat a satsuma . . . twenty minutes to get from one end of his branch to the other . . . and an hour to scratch his bottom. But Slow Loris didn't care. He had a secret . . ."
        (you can run this command with 'C-g C-r C-o C-w M-n M-e M-w C-d C-i C-g C-i C-t)

        g-r-o-w-n   e-w   d-i-g   i-t

        Damn! That's almost a mnemonic...for something?

        Ah! I got it. In order to use the "one true editor" you have

        g-r-o-w   n-e-w   d-i-g-i-t

        At least one. Several is better :)


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re^2: Multi-line comments in perl code?
by mrguy123 (Hermit) on Jul 16, 2006 at 11:05 UTC
    Hi loris.
    I have used emacs quite a lot in the past (a few years actually), and had quite a comfortable time with many things (including comments). Since then I have moved to a company where vi is the standard, and although it took me a while to get used to it (what in the %$!* is escape mode?) I eventually managed to regain all my old editing tools along with a few new ones (":s 1,25" is usually enough to comment out lines 1-25). What my question was (and after a lengthy discussion I assume that the answer is no) is whether I can write multi-line comments in Perl without perlpod. Although the answer is negative, I have learned about a few new tools that can make comments easier.
    Thanks for your good advice,
    mrguy123
Re^2: Multi-line comments in perl code?
by doom (Deacon) on Jul 17, 2006 at 23:05 UTC
    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://561170]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (8)
As of 2024-03-29 14:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found