开发者

Eclipse IDE Code formatting: turning off indentation

I like being able to use the (Java) Code Formatter in Eclipse, but Eclipse reformats this:

return new Element( OrderXMLGeneratorConstants.PERSONAL_DETAILS )
    .addContent( createElement( OrderXMLGeneratorConstants.FIRST_NAME, firstName ) )
    .addContent( createElement( OrderXMLGeneratorConstants.LAST_NAME, lastName ) )
    .addContent( createElement( OrderXMLGeneratorConstants.EMAIL, email ) );

to

return new Element( OrderXMLGeneratorConstants.PERSONAL_DETAILS )
                            开发者_高级运维                                       .addContent( createElement( OrderXMLGeneratorConstants.FIRST_NAME, firstName ) )
                                                                   .addContent( createElement( OrderXMLGeneratorConstants.LAST_NAME, lastName ) )   
                                                                   .addContent( createElement( OrderXMLGeneratorConstants.EMAIL, email ) )

How can I use the Code Formatter without getting this ridiculous amount of indentation?

Thanks.


Go to Windows -> Preferences :

In the dialog, select Java -> Code Style -> Formatter and select Edit.

Under the line wrapping tab, Function Calls -> Qualified invocations, you select indent by one, or Default Indentation at the bottom drop down menu (Indentation policy)

This one is probably set to Indent on column... this is what you do NOT want.

Edit and note : I use Helios SR1. I think the options are the same on Ganymede or Galileo though.


You should be able to modify the formatter settings. Go to window->preferences->java->code style->formatter. I think you need to look at the indentation policy on the line wrapping tab.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜