4

in rubymine it is easy to code out html with code -> line comment, but how do you comment multiple lines in ruby.

%= "this is a test %>

to

#= "this is a test %>
bonhoffer
  • 1,421
  • 2
  • 23
  • 38

3 Answers3

8

Select the lines you want to comment out, and do CMD+/ (forward slash) on a Mac. On a PC I'm assuming the same thing is CTRL+/

You can un-comment the same way, and you can also comment single lines out with the same keystroke. It doesn't really matter where your cursor is on the line. As long as a part of the line has been selected, the comment will include the whole line.

D. Simpson
  • 1,882
  • 17
  • 32
3

Ruby does have multiline comments, although they use a relatively strange syntax:

=begin
some text or code here
=end

Note that both the =begin and =end delimiters have to be at the very beginning of the line, nothing else should be on the same line.

halfdan
  • 33,545
  • 8
  • 78
  • 87
  • that is helpful -- i wish rubymine would automatically line comment out the region of interest. thanks for the tip. – bonhoffer Apr 18 '11 at 16:00
0

to comment some think like this

=begin
  your code is commented out
  this line is also commented
=end

select lines and press ctrl+shift+/ to comments some think like this

#your code is commented out
#this line is also commented

select lines and press ctrl+/

Asnad Atta
  • 3,855
  • 1
  • 32
  • 49