如何配置eclipse以保持这种代码格式? [英] How to configure eclipse to keep this code format?

查看:155
本文介绍了如何配置eclipse以保持这种代码格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码来自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 在eclipse中。您可以在以下路径中找到它:

You have to using Code Formatter in eclipse. You can find it in following path:


  1. windows menu and in 首选项 item。

  2. 转到左侧树中的 java

  3. 转到代码样式 java 的子树。

  4. 选择 Formatter leaf。

  5. 点击编辑按钮并编辑自定义结合并保存。

  1. windows menu and in Preferences item.
  2. go to java in left tree.
  3. go to code style sub-tree of java.
  4. select Formatter leaf.
  5. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆