Does Ruby have block comments?
If not, is there an efficient way of inserting #
in front of a block of highlighted code in TextMate?
A multi-line comment begins with the =begin token and ends with the =end token. These tokens should start at the beginning of the line and be the only thing on the line. Anything between these two tokens is ignored by the Ruby interpreter. lines are ignored by the Ruby interpreter.
The first is called a single line comment and, as implied, only applies to a single line in the "source code" (the program). The second is called a Block comment and refers usually refers to a paragraph of text. A block comment has a start symbol and an end symbol and everything between is ignored by the computer.
Multiline comments Multiple-line comments can be added by using =begin and =end syntax (also known as the comment block markers) as follows: #!/usr/bin/ruby -w =begin This is a multiline comment.
You can do
=begin [Multi line comment] =end
=begin
and =end
must be at the beginning of the line (not indented at all).
Source
Also, in TextMate you can press Command + / to toggle regular comments on a highlighted block of code.
Source
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.
In TextMate, you can alt-drag vertically to select a column of text. This will duplicate the insertion point across all the lines you select, so you can insert or delete multiple #
s at once.
UPDATE: Also in TextMate, assuming you have the right language selected, Cmd + / will toggle commenting every line in a selection regardless of language.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With