Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: What is the easy way to comment out chunk of Perl Code

by ickyb0d (Monk)
on Nov 18, 2005 at 19:22 UTC ( [id://509914]=note: print w/replies, xml ) Need Help??


in reply to What is the easy way to comment out chunk of Perl Code

I'm pretty sure there isn't anyway. BUT! If you use vim, there's always vimscripts!

For the vimscript below to work just put it in your .vimrc file. It assumes you have marked a maker 'a' (':mark a' while NOT in insert mode) at the beginning of where you want your un/comment block. Then just scroll down to where you want it to end and type in ',cb#' (while NOT in insert mode) to comment out the block. Alternatively you can type in ',ucb#' to uncomment a block of code.

nmap ,cb# :'a,.s/^/#/gi<CR>:nohl<CR> nmap ,ucb# :'a,.s/^#//g<CR>:nohl<CR>

Since perl doesn't have a standard IDE, i think the answer to this question is largely going to depend on what editor your using for developement.

Replies are listed 'Best First'.
Re^2: What is the easy way to comment out chunk of Perl Code
by cees (Curate) on Nov 18, 2005 at 20:49 UTC

    I use the BlockComment plugin for vim which I mapped to _c and _C to comment an uncomment respectively.

    It works really well with the highlighting mode that vim uses. For example, go to the start of a block (function, loop, if statement) then hit Shift-V % to highlight the entire block and then _c to comment it out. Or hit Shift-V 20j to highlight the next 20 lines below the cursor, then hit _c to comment or _C to uncomment.

    Oh, and it works for many different languages, not just perl.

Re^2: What is the easy way to comment out chunk of Perl Code
by philcrow (Priest) on Nov 18, 2005 at 19:43 UTC
    I couldn't get that to work with nmap ,cb#

    But it worked great with map <F8>. Thanks.

    Phil

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-19 21:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found