首页 > 解决方案 > 如何防止 Eclipse 格式化程序删除块注释中的“对齐空格”?

问题描述

我们正在使用 google 的“Java 风格”的(略微采用)版本,只需在 eclipse 中导入相应的 XML(来自此处)。

这很好用,但我们看到块注释存在一个烦人的问题。

我们的文件确实有一个生成的版权标题,如下所示:

/* some text followed by some spaces      */
/* so that all lines are equally spaced   */

当使用google风格的xml时,上面变成了

/* some text followed by some spaces */
/* so that all lines are equally spaced */

使用格式化Eclipse [built-in]程序格式化时,不会删除空格!

我仔细检查了 google XML 文件,并遇到了这一行:

<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" false="true"/>

但是,唉,改变那条线来使用false并没有改变任何东西。

问:如何修改那个 google 风格的 XML 文件,使空格留在块注释中?

标签: javaeclipseformatter

解决方案


Eclipse [内置] 样式已关闭“启用标题注释格式”(org.eclipse.jdt.core.formatter.comment.format_headerXML 中的值)。所以它只留下标题注释。


推荐阅读