Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Control indentation in Java multiline method calls in IntelliJ

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

enter image description here

Or this:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

>Solution :

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");
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading