How to configure eclipse to keep this code format?

我是研究僧i 提交于 2019-12-07 22:55:07

问题


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())
        )
    );
}

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())
        ));
}

How to configure eclipse to keep to first format style? I tried a lot, but not works.


回答1:


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

  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.

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.

following link is useful:

  • http://www.peterfriese.de/formatting-your-code-using-the-eclipse-code-formatter/


来源:https://stackoverflow.com/questions/9989142/how-to-configure-eclipse-to-keep-this-code-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!