Josh M.
Josh M.

Reputation: 27831

How to stop IntelliJ IDEA from adding extra indentation to multi-line statements?

Bad (what IntelliJ does):

return !enabled ||
    (
        !name.isBlank() &&
            !email.isBlank() &&
            !phone.isBlank()
    );

Better (what I want it to do):

return !enabled ||
(
    !name.isBlank() &&
    !email.isBlank() &&
    !phone.isBlank()
);

Is there a way to configure IntelliJ IDEA to not add the extra indentation for multi-line boolean statements?


I also don't like the formatting when writing HQL (or any multi-line string), e.g.:

Bad:

@Query(
    "SELECT x " +
        "FROM Something x " +
        "WHERE " +
        "blah = 1 AND " +
        "name = 'blah'"
)

Good:

@Query(
    "SELECT x " +
    "FROM Something x " +
    "WHERE " +
        "blah = 1 AND " +
        "name = 'blah'"
)

Is there a way to configure IntelliJ IDEA to format HQL the way I like it (shown here)?

Upvotes: 3

Views: 434

Answers (1)

CrazyCoder
CrazyCoder

Reputation: 402513

File | Settings | Editor | Code Style | Java, Wrapping and Braces, Binary Expressions: Align when multiline:

Align when multiline

Upvotes: 2

Related Questions