Krishna Kalyan
Krishna Kalyan

Reputation: 1702

java eclipse formatting (unnecessary white space if condition )

On formatting my code Ctrl + Shift + f This is how my code looks

if (item == null) {}

Is it possible to get it formatted like

if(item == null) {}

Thanks,

Upvotes: 2

Views: 978

Answers (2)

NotGaeL
NotGaeL

Reputation: 8484

You can configure formatting profiles on Eclipse.

Just go to Eclipse preferences > Java > Code Style > Formatter.

As the other answer specifies (damn it, that was fast!) you'll find the particular option you're looking for on the before opening parenthesis checkbox displayed when selecting control statements > 'if else' on the white space tab on the edit profile dialog.

Check out these resources too:

http://www.ralfebert.de/archive/java/source_formatting/

Best Eclipse Code Formatters?

Upvotes: 2

Ninad Pingale
Ninad Pingale

Reputation: 7069

You can go to Window > Preferences > Java > Code Style > formatter > Edit > and uncheck option "before opening parenthesis".

enter image description here

Upvotes: 7

Related Questions