Ruby-on-rails 在 Gedit 中阻止评论?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7649626/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 02:05:49  来源:igfitidea点击:

Block commenting in Gedit?

ruby-on-railsruby-on-rails-3gedit

提问by Jason Kim

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​​ 编程,我讨厌将 # 单独放在行上。

回答by Soundar Rathinasamy

1.Install gedit plugins

1.安装gedit插件

 sudo apt-get install gedit-plugins

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

2.转到编辑->首选项->插件->并启用代码注释

3.Ctl+m to comment block of codes

3.ctl+m 注释代码块

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

4.Ctl+Shift+m​​ 取消注释代码块

回答by HymanWink

Ruby has block commenting...

Ruby 有块注释...

=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.

这将避免需要在每一行添加 #... 但是,我认为 Gedit 默认不会将突出显示的代码转换为注释行。

回答by drugan

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.

代码注释插件显然很适合#(hash) 样式的注释,但是如果您需要用双 // 斜杠或任何其他自定义注释样式注释掉 php 代码块怎么办?例如,在注释符号后添加一两个空格。

  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.

  1. 转到 Edit->Preferences->Plugins-> 并启用外部工具插件。

  2. 转到工具-> 管理外部工具。

  3. 在工具侧栏下单击添加 (+) 符号,调用您的新工具“注释掉”并将此代码添加到编辑字段中:

    #!/bin/bash

    # comment out current selection

    # comment style

    comment="// "

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

  4. 设置您的工具。

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

快捷键:Alt+/(将光标放在字段中并按 Alt+/ 或任何其他键)

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"

  1. 工具名称:“取消注释”。

  2. 快捷键:Alt+Backspace

  3. 要插入编辑字段的代码:

    #!/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.

享受。

回答by Dennis

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

回答by janders223

=begin

Code to be commented out

=end

回答by Widor

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

看起来代码注释插件可以做到吗?http://live.gnome.org/GeditPlugins

回答by Dave Newton

Get the "code comment" plugin.

获取“代码注释”插件。

回答by fl00r

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

你应该试试gmate!它是一个很酷的插件包,用于在 gedit 下进行 Ruby(不仅仅是 Ruby)开发。

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

您可以像 Sublime 或 TextMate 一样注释和取消注释一堆行