【问题标题】:Cannot figure out how to properly configure eclipse formatter无法弄清楚如何正确配置 eclipse 格式化程序
【发布时间】:2011-02-18 07:34:37
【问题描述】:

我在使用 Eclipse 格式化程序时遇到问题,我似乎无法弄清楚。

如果我有一行包含超过 80 个字符的 cmets 代码,例如:

Something something = new Something(somethingElse) // some comments here about the code.

那么我第一次运行格式化程序时,它会正确设置它,例如:

Something something = new Something(somethingElse) // some comments here
                                                   // about the code.

但是,如果我稍后再次运行格式化程序,它将更改为:

Something something = new Something(somethingElse) // some comments here
// about the code.

我觉得这里应该缺少一些明显的东西,但我已经查看了所有我能找到的格式化程序设置,但还没有找到防止这种行为的方法。有人对此有任何见解吗?

谢谢

【问题讨论】:

    标签: java eclipse comments whitespace formatter


    【解决方案1】:

    第二次运行格式化程序时,它不明白// about the code 是上一行注释的一部分,它决定该行需要与代码齐平。查看设置,我没有看到明显的解决方法。我建议要么只将短 cmets 放在行尾和/或将 cmets 放在上面的行上。 (或者,不使用格式化程序,这通常是我的偏好。)

    // some comments here about the code. If it's long enough it'll wrap
    // like this.
    Something something = new Something(somethingElse) // Short note
    

    【讨论】:

      猜你喜欢
      • 2020-06-21
      • 2021-12-26
      • 1970-01-01
      • 2019-10-26
      • 2019-03-12
      • 1970-01-01
      • 1970-01-01
      • 2020-12-01
      • 1970-01-01
      相关资源
      最近更新 更多