Block commenting-out

hi,

can anyone tell me how to bulk comment-out lines of code rather than
#'ing each line?

thanks

On 14.08.2006 15:51, newyorkdolluk wrote:

hi,

can anyone tell me how to bulk comment-out lines of code rather than
#'ing each line?

thanks

15:56:48 [~]: ruby <<XXX

puts 1
=begin
foo
adha sdjas dha dad +asdp+adp+ad+
=end
puts 2
XXX
1
2

In short, use “=begin” and “=end”.

Kind regards

robert

On 8/14/06, newyorkdolluk [email protected] wrote:

hi,

can anyone tell me how to bulk comment-out lines of code rather than
#'ing each line?

thanks

=begin

your code

=end

I have to know, how does a New York Doll end up in the UK?

newyorkdolluk wrote:

hi,

can anyone tell me how to bulk comment-out lines of code rather than
#'ing each line?

thanks

Komodo can do block commenting out, prepending “#”. Scite prepends
“##” so you know that is was done in bulk fashion. Your editor must
hvae something of the sort to block comment and uncomment.

On 14/08/06, newyorkdolluk [email protected] wrote:

hi,

can anyone tell me how to bulk comment-out lines of code rather than
#'ing each line?

thanks

=begin
This is a comment
on multiple lines
=end

Farrel

On Tue, Aug 15, 2006 at 03:42:20PM +0900, Gene T. wrote:

“##” so you know that is was done in bulk fashion. Your editor must
hvae something of the sort to block comment and uncomment.

Vim could, of course, do it via a substitution iterating over a number
of lines indicated by a prepended number. I’m sure EMACS (Esc Meta Alt
Ctrl Shift) could do something similar, but with four times as many keys
involved.

What, me biased? Never.

If you highlight the lines you want commented out in Textmate, then
press Command + /, it will prepend # to every line. It works quite
well. Plus, if you highlight and Command + / again, it’ll remove the
#s.

:wink:

M.T.

With Ruby In Steel you just mark a block and click a button to comment
or
uncomment :wink:

best wishes
Huw C.

http://www.sapphiresteel.com
Ruby P.ming In Visual Studio 2005

Huw C. wrote:

With Ruby In Steel you just mark a block and click a button to comment or
uncomment :wink:

But… but… that requires taking your hand off the keyboard!

Heresy!

:slight_smile:

On 15-aug-2006, at 11:35, Huw C. wrote:

With Ruby In Steel you just mark a block and click a button to
comment or
uncomment :wink:

Click a button? Isn’t that what most people try to avoid when editing
files? :slight_smile:

Chad P. [email protected] writes:

Komodo can do block commenting out, prepending “#”. Scite prepends
“##” so you know that is was done in bulk fashion. Your editor must
hvae something of the sort to block comment and uncomment.

Vim could, of course, do it via a substitution iterating over a number
of lines indicated by a prepended number. I’m sure EMACS (Esc Meta Alt
Ctrl Shift) could do something similar, but with four times as many keys
involved.

What, me biased? Never.

M-x comment-region

Bind to every key you like (I don’t use it often).

C-u M-x comment-region (or M-x uncomment-region) will uncomment.

On Aug 15, 2006, at 6:42 AM, Christian N. wrote:

What, me biased? Never.

M-x comment-region

Bind to every key you like (I don’t use it often).

C-u M-x comment-region (or M-x uncomment-region) will uncomment.

Try M-; (comment-dwim).

– Daniel

Daniel H. [email protected] writes:

involved.

What, me biased? Never.

M-x comment-region

Bind to every key you like (I don’t use it often).

C-u M-x comment-region (or M-x uncomment-region) will uncomment.

Try M-; (comment-dwim).

I knew there was an easier way, but M-; requires using transient-mark
mode (shudder). Well, not too bad in Emacs 22, C-SPC, C-SPC.

“Alex Y.” [email protected] wrote in message
news:[email protected]

Huw C. wrote:

With Ruby In Steel you just mark a block and click a button to comment or
uncomment :wink:

But… but… that requires taking your hand off the keyboard!

Heresy!

Sorry, my mind must have been warped by doing too much Smalltalk
programming
lately. You can, of course, use the keyboard: CTRL+E,C to comment,
CTRL+E, U
to uncomment, or you can define your own favourite keystrokes. :slight_smile:

best wishes
Huw C.

http://www.sapphiresteel.com
Ruby P.ming In Visual Studio 2005

On Wed, Aug 16, 2006 at 12:53:24AM +0900, Christian N. wrote:

Ctrl Shift) could do something similar, but with four times as

Try M-; (comment-dwim).

I knew there was an easier way, but M-; requires using transient-mark
mode (shudder). Well, not too bad in Emacs 22, C-SPC, C-SPC.

What do “comment-region” and “comment-dwim” mean in practical terms in
this case?

How many modes are there to emacs?

On Tue, Aug 15, 2006 at 08:35:10PM +0900, Huw C. wrote:

Sorry, my mind must have been warped by doing too much Smalltalk programming
lately. You can, of course, use the keyboard: CTRL+E,C to comment, CTRL+E, U
to uncomment, or you can define your own favourite keystrokes. :slight_smile:

. . . and to “mark a block” in preparation for this, I gather you have
to use arrow keys and the Shift key, or take a hand off the keyboard.
Yes?

Chad P. [email protected] writes:

What do “comment-region” and “comment-dwim” mean in practical terms in
this case?

comment-region:

Comment or uncomment each line in the region.
With just C-u prefix arg, uncomment each line in region beg … end.
Numeric prefix arg means use arg comment characters.
If arg is negative, delete that many comment characters instead.
By default, comments start at the left margin, are terminated on each
line,
even for syntax in which newline does not end the comment and blank
lines
do not get comments. This can be changed with `comment-style’.

comment-dwim:

Call the comment command you want (Do What I Mean).
If the region is active and transient-mark-mode' is on, callcomment-region’ (unless it only consists of comments, in which
case it calls uncomment-region'). Else, if the current line is empty, insert a comment and indent it. Else if a prefix arg is specified, callcomment-kill’.
Else, call comment-indent'. You can configurecomment-style’ to change the way regions are
commented.

How many modes are there to emacs?

492 matches for “-mode$” in buffer: Apropos

:slight_smile:

On Wed, Aug 16, 2006 at 03:25:49AM +0900, Christian N. wrote:

If arg is negative, delete that many comment characters instead.
Else, if the current line is empty, insert a comment and indent it.
Else if a prefix arg is specified, call comment-kill'. Else, callcomment-indent’.
You can configure `comment-style’ to change the way regions are commented.

Thanks. That satisfies my curiosity.

How many modes are there to emacs?

492 matches for “-mode$” in buffer: Apropos

Holy crap.

In vim you could put this in your .vimrc file:
map ,# :s/^/#/

mark the block you want to comment and then hit ,# (or whatever else you
want to map it to), and its done.

Cheers.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs