Cannot remove block comment in Eclipse after formatting(格式化后无法删除 Eclipse 中的块注释)
问题描述
Eclipse 的自动格式化程序会更改块注释,因此 Source > Remove Block Comment 不会完全删除块注释.Source > Add Block Comment 将时钟注释的开始和结束添加到代码行中,但是在运行 Formatter (Ctrl + Shift + F) 后,它会包装代码行并在每行的开头添加一个星号.当我尝试使用 Source > Remove Block Comment 删除块注释时,块注释的开头和结尾被删除,但每行开头的星号不会被删除.
Eclipse's automatic formatter changes block comments such that the Source > Remove Block Comment does not completely remove the block comment. Source > Add Block Comment adds the start and end of the clock comment to the lines of code, but after running the Formatter (Ctrl + Shift + F), it wraps the lines of code and adds an asterisk to the start of each line. When I try to remove the block comment with Source > Remove Block Comment, the start and end of the block comment is removed, but the asterisks at the beginning of each line is not removed.
如何防止 Eclipse 添加这些星号,或者在删除块注释的开头和结尾时删除星号?
How do I prevent Eclipse from adding these asterisks, or remove the asterisks when it removes the start and end of the block comment?
示例:
这样的代码:
String abc="abc";
String def="def";
System.out.println(abc+def);
System.exit(0);
添加块评论后变成这样:
Becomes like this after adding block comments:
/* String abc="abc";
String def="def";
System.out.println(abc+def);
*/ System.exit(0);
应用格式后变成这样:
/*
* String abc="abc"; String def="def"; System.out.println(abc+def);
*/System.exit(0);
使用删除块评论功能后,结果如下:
Which ends up like this after using the Remove Block Comment function:
* String abc="abc"; String def="def"; System.out.println(abc+def);
System.exit(0);
推荐答案
这可能有点晚了,但我通过禁用块评论格式解决了这个问题.
This may be a little late in the game, but I fixed this by disabling block comment formatting.
Windows -> Preferences -> Java -> Code Style -> Formatter -> Edit -> Comments
然后取消选中启用块注释格式.
这篇关于格式化后无法删除 Eclipse 中的块注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:格式化后无法删除 Eclipse 中的块注释


- 如何指定 CORS 的响应标头? 2022-01-01
- 获取数字的最后一位 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
- 转换 ldap 日期 2022-01-01
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01