Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ Align arguments to opening parenthesis?

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);
like image 407
ArtOfWarfare Avatar asked Jul 13 '16 14:07

ArtOfWarfare


1 Answers

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

like image 53
yole Avatar answered Sep 29 '22 08:09

yole