无法弄清楚如何正确配置 Eclipse 格式化程序
我遇到了 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第二次运行格式化程序时,它不理解
// about the code
是上面行注释的一部分,并且它决定该行需要与代码齐平。浏览设置,我没有看到明显的解决方法。我建议要么只在行尾放置简短的注释和/或将注释放在上面的行上。 (或者,不使用格式化程序,这通常是我的偏好。)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.)