简体   繁体   中英

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), eg:

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)?

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

多行时对齐

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM