简体   繁体   English

IntelliJ 中 Java 多行方法调用中的控制缩进

[英]Control indentation in Java multiline method calls in IntelliJ

IntelliJ seems to only have two configurations for multiline method call parameters. IntelliJ 似乎只有两种多行方法调用参数的配置。 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.这是使用“编辑器 -> 代码样式 -> Java -> 包装和大括号 -> 方法调用 arguments -> 多行对齐”选项控制的。 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).我相信您正在寻找的是“连续缩进”(编辑器 -> 代码样式 -> 制表符和缩进 -> 连续缩进。禁用“多行时对齐”时,它使用此缩进大小(看起来你默认值为 8)。

When I reformat with this setting I get:当我使用此设置重新格式化时,我得到:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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