Home > other >  Control indentation in Java multiline method calls in IntelliJ
Control indentation in Java multiline method calls in IntelliJ

Time:04-08

IntelliJ seems to only have two configurations for multiline method call parameters. They either appear like this:

enter image description here

Or this:

enter image description here

This is controlled using the "Editor -> Code Style -> Java -> Wrapping and Braces -> Method call arguments -> Align when multiline" option. However, I have not found any settings to achieve my actual preferred formatting, this:

enter image description here

That would not be quite as infuriating if pressing backspace in the editor didn't delete the entire line break, instead of just the tabs, but preferably I'd like to be able to control how many tabs are used, i.e. only one more than the method call declaration itself. Any help towards this would be enormously appreciated.

CodePudding user response:

I believe what you're looking for is the "Continuation Indent" (Editor -> Code Style -> Tabs and Indents -> Continuation Indent. When "Align when multiline" is disabled, it uses this indent size (and it appears that you have the default of 8).

When I reformat with this setting I get:

foo.foo().bar("arg1",
  "arg2");
  • Related