java 如何删除IDEA中的所有注释行?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33933720/
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-11-02 22:18:30  来源:igfitidea点击:

How to delete all comment lines in IDEA?

javaintellij-ideaide

提问by Macilias

I′m searching for a quick way to get rid of all comments in a file.

我正在寻找一种快速删除文件中所有评论的方法。

Looking for a keyboard shortcut or a quick and easy alternative.

寻找键盘快捷键或快速简便的替代方法。

Any suggestions?

有什么建议?

EDIT

编辑

I would like particularly to delete only the out commented lines, so ones that start with //, not the block comments - which normally are meant for java-doc.

我想特别删除注释行,所以那些以 开头的行,而//不是块注释 - 通常用于 java-doc。

回答by Bas Leijdekkers

You could use Find & Replace (Ctrl/Cmd+R). Search In Comments Only(option under the little cog menu), enable regex search and search for string ^//.*. Replace with the empty string.

您可以使用查找和替换 ( Ctrl/Cmd+ R)。仅在评论中搜索(小齿轮菜单下的选项),启用正则表达式搜索并搜索 string ^//.*。替换为空字符串。

回答by Francisco Hernandez

Select all lines you want comment/uncomment and use through menu

选择所有要注释/取消注释的行并通过菜单使用

Code -> comment with line comment

代码 -> 带有行注释的注释

or

或者

Code -> comment with block comment

代码 -> 带有块注释的注释