tpdi
tpdi

Reputation: 35141

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.

Upvotes: 0

Views: 819

Answers (2)

shsteimer
shsteimer

Reputation: 28800

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.

Upvotes: 1

E-K
E-K

Reputation: 1491

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.

Upvotes: 3

Related Questions