How do you fix intellij strange string indentation?
Asked Answered
P

1

35

Intellij keeps on formatting my strings like this, its annoying...

How do I fix it so the lines all line up?

PreparedStatement p = s.prepare(
        "select distinct resource, uid, role " +
                "from role " +
                "where person_uuid=? " +
                "order by role, resource, uid");

I.E.:

PreparedStatement p = s.prepare(
        "select distinct resource, uid, role " +
        "from role " +
        "where person_uuid=? " +
        "order by role, resource, uid");
Phrase answered 10/8, 2013 at 8:11 Comment(2)
I'm a recent IntelliJ convert, and I was wondering the same thing...Jephthah
I don't have an informed answer about IntelliJ, but Eclipse has a preference page with per-language formatting rules. Can you find such a page in the IntelliJ preferences?Bourguiba
S
46

You can adjust the formatting in Project Settings -> Code Style -> Java -> Wrapping and Braces. The option you are looking for should be either "Method call arguments" or "Binary Expressions"

Septa answered 10/8, 2013 at 9:16 Comment(3)
Indeed. Binary Expressions -> Align When MultilineLocarno
Eclipse has much more fine grained support for adjustments here, which makes it hard to conform to eclipse code styles in this case.Embouchure
Works fine as long as you are not combining a Kotlin Elvis operator with a long exception string :)Sidon

© 2022 - 2024 — McMap. All rights reserved.