简体   繁体   中英

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:

在此处输入图像描述

Or this:

在此处输入图像描述

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:

在此处输入图像描述

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, ie only one more than the method call declaration itself. Any help towards this would be enormously appreciated.

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");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM