IntelliJ Align arguments to opening parenthesis?
Asked Answered
S

1

7

When I split arguments onto multiple lines in IntelliJ, it puts the argument at a slight indent from the line above. For example:

ClassName.staticMethod(argument1,
    argument2,
    argument3);

Quick, what are the arguments above? Okay, that's easy because of the example names I chose, but how about below? Which arguments are going to staticMethod below?

ClassName.staticMethod(this.instanceMethod(argument1,
    argument2),
    argument3);

staticMethod is taking the results of a call to instanceMethod and argment3, but with IntelliJ's default formatting, at a glance you'd completely miss the fact that argument2 is an argument for instanceMethod, not staticMethod.

This is a freaking terrible default behavior. How can I get it to properly line arguments up, as in the modified examples below?

ClassName.staticMethod(argument1,
                       argument2,
                       argument3);

ClassName.staticMethod(this.instanceMethod(argument1,
                                           argument2),
                       argument3);
Someway answered 13/7, 2016 at 14:43 Comment(0)
P
8

Settings | Editor | Code Style | Java | Wrapping and Braces | Method call arguments | [x] Align when multiline

Pompea answered 13/7, 2016 at 14:46 Comment(1)
Great, thanks! IntelliJ has far too many settings (and far too many of them have the incorrect defaults).Someway

© 2022 - 2024 — McMap. All rights reserved.