默认的 Eclipse 格式化程序以一种非常有趣的方式格式化我的 Java 代码.
The default Eclipse formatter formats my Java code in a really funny way.
例如:hello.show().x().y()
会奇怪地被格式化为 x()
和 .y()
,并放在单独的一行.
For example: hello.show().x().y()
would oddly be formatted as x()
and .y()
, and be placed on a separate line.
还有其他可以做得更好的基本格式化程序吗?
Are there any other basic formatters that can do a better job?
非常欢迎提供示例和链接.
Examples and links are very welcome.
我总是将 Eclipse 中的格式化程序更改为 Java Convention 并将选项卡策略更改为始终使用空格而不是选项卡或混合选项卡和空间.有时我还将线宽更改为 100 或 120(80 个字符在我的显示器中太窄了).
I always change the formatter in Eclipse to Java Convention AND change the tab policy to always use space instead of tab or mixing of tab and space. Sometime I change also the line width to be 100 or 120 (80 characters is just too narrow in my monitor).
关于您的具体要求:是的,您可以更改此行为.转到格式化程序首选项并创建您自己的配置文件.在选项卡 Line Wrapping 上修改它并取消选中 Prefer wrapping external expressions (keep nested expression on a line)
.
Regarding your specific request: yes you can change this behavior. Go to the Formatter preference and create your own profile. Modify it on tab Line Wrapping and uncheck Prefer wrapping outer expressions (keep nested expression on one line)
.
更多信息:https://bugs.eclipse.org/bugs/show_bug.cgi?id=313524
这篇关于最好的 Eclipse 代码格式化程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!