Block commenting in Gedit?

Ruby on-RailsRuby on-Rails-3Gedit

Ruby on-Rails Problem Overview


Is there a way to comment out a chunk of highlighted code?

I am programming in ruby, and I hate putting # on lines individually.

Ruby on-Rails Solutions


Solution 1 - Ruby on-Rails

1.Install gedit plugins

 sudo apt-get install gedit-plugins

2.Go to Edit->Preference->Plugins-> and enable Code Comment

3.Ctl+m to comment block of codes

4.Ctl+Shift+m to uncomment block of codes

Solution 2 - Ruby on-Rails

Ruby has block commenting...

=begin
    Insert comment here
=end

This will avoid the need to add # to each line... However, I don't think Gedit will convert highlighted code into commented lines by default.

Solution 3 - Ruby on-Rails

Code Comment plugin obviously is a good one for # (hash) style commenting but what if you need comment out php code block with double // slashes or any other custom commenting style? For example, with one or two whitespaces added after the comment symbol.

  1. Go to Edit->Preferences->Plugins-> and enable External Tools plugin.

  2. Go to Tools->Manage External Tools.

  3. Under the Tools side bar click add (+) sign, call your new tool "Comment out" and add this code into the Edit field:

    #!/bin/bash

    # comment out current selection

    # comment style

    comment="// "

    xargs -i -d\\\n echo $comment{}

  4. Set up your tool.

Shortcut Key: Alt+/ (put the cursor in the field and press Alt+/ or any other keys)

Save: Nothing

Input: Current selection (default to document)

Output: Replace current selection

Applicability: All documents? All languages? (change if you need)

To uncomment commented block of code do the same things except below ones.

  1. Name of the Tool: "Uncomment".

  2. Shortcut Key: Alt+Backspace

  3. Code to insert into the Edit field:

    #!/bin/bash

    # uncomment current selection

    # comment symbols to remove

    uncomment="^\/\/ "

    xargs -i -d\\\n echo {} | sed -ne "s/$uncomment//p"

Change comment/uncomment variable value (double slashes and space) with your desired commenting style.

Enjoy.

Solution 4 - Ruby on-Rails

Just use a multi-line comment.

Example:

=begin
Anything between a line consisting only of =begin
and a line consisting only of =end
is treated as a comment.
=end

Solution 5 - Ruby on-Rails

=begin

Code to be commented out

=end

Solution 6 - Ruby on-Rails

Looks like Code Comment plugin would do it? http://live.gnome.org/GeditPlugins

Solution 7 - Ruby on-Rails

Get the "code comment" plugin.

Solution 8 - Ruby on-Rails

You should try gmate! It is a package of cool plugins for Ruby (and not only Ruby) developement under gedit.

You can comment and uncomment bunch of lines like in Sublime or TextMate

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJason KimView Question on Stackoverflow
Solution 1 - Ruby on-RailsSoundar RathinasamyView Answer on Stackoverflow
Solution 2 - Ruby on-RailsJackWinkView Answer on Stackoverflow
Solution 3 - Ruby on-RailsdruganView Answer on Stackoverflow
Solution 4 - Ruby on-RailsDennisView Answer on Stackoverflow
Solution 5 - Ruby on-Railsjanders223View Answer on Stackoverflow
Solution 6 - Ruby on-RailsWidorView Answer on Stackoverflow
Solution 7 - Ruby on-RailsDave NewtonView Answer on Stackoverflow
Solution 8 - Ruby on-Railsfl00rView Answer on Stackoverflow