views:

867

answers:

3

Does Ruby have block comments?

If not, is there an efficient way of inserting # in front of a block of highlighted code in TextMate?

+13  A: 

You can do

=begin
  [Multi line comment]
=end

Source

Also, in TextMate you can press Command + / to toggle regular comments on a highlighted block of code.

Source

Garry Shutler
+6  A: 

Ruby has documentation comments - they look like this:

=begin
...
=end

Not perfect but they get the job done in a pinch.

[Edit] It is important to note that =begin and =end must be at the beginning of their respective lines.

Andrew Hare
I would add that you need =begin and =end to be at the beginning of the line.
epochwolf
Good catch! I edited to say as much - thanks!
Andrew Hare
thanks. no wonder it didn't work (which is why i made this thread in the first place).
alamodey
A: 

http://gist.github.com/599183

I wrote this to allow me to call a command from TM (for me it's mac 3) which takes the selected text and prepends '=begin' and appends '=end'. I did it primarily so I could fold large comment blocks. Just add a new command to your bundle editor and add this. Be sure to set input to selected text. Also this was just a quick little thing I came up with on the spot so no guarantees.

Jonathan Jackson