Slot Machine
Slot Machine

Reputation: 71

Formatting a one line if statement in Eclipse (2019)

I understand that this question has been answered before, but those answers no longer apply to the current version of Eclipse. If this is not the appropriate way to re-ask a question, I apologize in advance.

When I use shift+ctrl+f to reorganize a class I have the following happen to my one-line if statements

if (true) doThis();

changed to

if (true)
    doThis();

How can I make shift+ctrl+f auto organize to be like the first statement?

Upvotes: 0

Views: 749

Answers (1)

Thomas
Thomas

Reputation: 5094

From the menu:

Window -> Preferences

In Preferences:

Java -> Code Style -> Formatter -> Click 'edit' enter image description here

New Lines -> In control statements -> 'if else' -> Keep simple 'if' on one line

enter image description here

Upvotes: 1

Related Questions