vendredi 28 mai 2021

Why does my Eclipse formatter move the condition and parenthesis to separate lines for my if statements and for loops?

When I reformat my java code in Eclipse (CTRL-SHIFT-F), it does weird things to my if statements. It puts the open parenthesis, the condition, and the closing parenthesis each on their own line.

Here is an example:

        if (
            x != null
        )
        {
          ...
        }

I want it to look like this:

        if (x != null)
        {
          ...
        }

Reformatting does the same thing to my for loops:

    for (
            int i = startIndex; i <= endIndex; i++
    )
    {
       ...
    }

I've tried going to Window -> Preferences -> Code Style -> Formatter. I can't find the option I need in order to fix this. Please help!

Aucun commentaire:

Enregistrer un commentaire