2

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,

Krishna Kalyan
  • 1,672
  • 2
  • 20
  • 43

2 Answers2

7

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

enter image description here

Ninad Pingale
  • 6,801
  • 5
  • 32
  • 55
2

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?

Community
  • 1
  • 1
NotGaeL
  • 8,344
  • 5
  • 40
  • 70