无法弄清楚如何正确配置 Eclipse 格式化程序

发布于 2024-08-31 23:56:28 字数 635 浏览 8 评论 0原文

我遇到了 Eclipses 格式化程序的问题,我似乎无法弄清楚。

如果我有一行代码的注释超过 80 个字符,例如:

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

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

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

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

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

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

谢谢

I am havinging a problem with eclipses formatter that i cannot seem to figure out.

If i have a line of code with comments that is over 80 characters, like:

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

then the first time i run the formatter, it will set it up correctly, like:

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

However, if i then run the formatter again later, it will change it to:

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

I feel like there should be something obvious here that i am missing, but i have looked through all the formatter settings that i could find and have yet to find a way to prevent this behaivor. Does anyone have any insight to this?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

剧终人散尽 2024-09-07 23:56:28

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

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

The second time the formatter is run, it doesn't understand that // about the code is part of the comment on the line above, and it decides that line needs to be flush with the code. Looking through the settings, I don't see an obvious way around it. I'd suggest either only putting short comments on the end of lines and/or putting the comments on the line above. (Or, not using the formatter, which is usually my preference.)

// some comments here about the code. If it's long enough it'll wrap
// like this.
Something something = new Something(somethingElse) // Short note
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文