如何配置eclipse以保持这种代码格式? [英] How to configure eclipse to keep this code format?
问题描述
以下代码来自playframework-2.0示例:
Following code is from a sample of playframework-2.0:
/**
* Display the dashboard.
*/
public static Result index() {
return ok(
dashboard.render(
Project.findInvolving(request().username()),
Task.findTodoInvolving(request().username()),
User.find.byId(request().username())
)
);
}
它看起来不错,但是当我使用eclipse的代码格式时,它变为:
It looks good, but when I use code format of eclipse, it becomes:
/**
* Display the dashboard.
*/
public static Result index() {
return ok(dashboard.render(
Project.findInvolving(request().username()),
Task.findTodoInvolving(request().username()),
User.find.byId(request().username())
));
}
如何配置eclipse以保持第一格式样式?我尝试了很多,但没有用。
How to configure eclipse to keep to first format style? I tried a lot, but not works.
推荐答案
你必须使用 Code Formatter $ c $ e>在eclipse中。您可以在以下路径中找到它:
You have to using Code Formatter
in eclipse. You can find it in following path:
-
windows
menu and in首选项
item。 - 转到左侧树中的
java
。 - 转到
代码样式
java
的子树。 - 选择
Formatter
leaf。 - 点击
编辑
按钮并编辑自定义结合并保存。
windows
menu and inPreferences
item.- go to
java
in left tree. - go to
code style
sub-tree ofjava
. - select
Formatter
leaf. - click
Edit
button and edit your customize formate and save it.
我建议您保存自定义环境,例如格式化程序,并在其他地方使用它。 Eclipse
在xml文件中保存 formatter
信息。你可以指定这个档案的路径。
I recomend you save your customization environment such as formatter and use it in others place. Eclipse
hold formatter
information in a xml file. you can specify path of this file.
以下链接很有用:
- http://www.peterfriese.de/formatting-your-code-using-the-eclipse-code-formatter/
这篇关于如何配置eclipse以保持这种代码格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!