Removing spaces from if if else block with eclipse formatting

I currently have an Eclipse formatter configured to format an if-else statement like this:

if(condition) {
  return foo;
}
else{
  return bar;
}

      

Notice the space between the closing parenthesis of the condition and the opening parenthesis of the true block - I'd like to remove that space.

There is Whitespace -> Control statements -> 'if else'

no option in the formatting profile to "close the closing parenthesis". There Blocks

is a "before opening parenthesis" option in the section , however this seems to only apply to the spurious block (and is disabled anyway).

I need to be missing an option somewhere - how can I disable this space?

I am using Eclipse Mars 4.5.0.

+3


source to share


3 answers


This is related to Eclipse Bug # 471145 (specifically to Mars / 4.5.0), which was reported on 2015-06-26, fixed on 2015-08-01 and will be included in Eclipse 4.5. 1 - which should be complete and ready to download by the end of September 2015 as part of the Mars coordinated service release .



0


source


You can do it under Windows -> Preferences -> Java -> Code Style -> Formatting -> Change Profile

enter image description here




I think what it does when you select another option from the dropdown you can see below

enter image description here

+1


source


Go to Windows > Preferences > Java > Code Style > Formatter > White Space

and to Control statements > Blocks

, deselect the "before opening" option :)

enter image description here

0


source







All Articles