![](/img/trans.png)
[英]Wrapping chained method calls on a separate line in Intellij for Java
[英]Can you customize how IntelliJ does auto format line wrapping on method declarations and method calls?
在这个answer
它显示了如何在IntelliJ中启用自动换行。
但是您可以进一步自定义它吗?
例如,如果您使用120的自动换行值对此进行自动格式化:
public void someMethodWithLotsOfArguments(int thisIsValue1, int thisIsValue2, int thisIsValue3, int thisIsValue4asdfasdfasdfasdfasdf, Double thisIsValue, int thisIsValue6, int thisIsValue7) {
它将变为:
public void someMethodWithLotsOfArguments(int thisIsValue1, int thisIsValue2, int thisIsValue3, int
thisIsValue4asdfasdfasdfasdfasdf, Double thisIsValue, int thisIsValue6, int thisIsValue7) {
有没有办法让它变得更聪明,并像这样格式化:
public void someMethodWithLotsOfArguments(int thisIsValue1,
int thisIsValue2,
int thisIsValue3,
int thisIsValue4asdfasdfasdfasdfasdf,
int thisIsValue5,
int thisIsValue6,
int thisIsValue7) {
或至少像:
public void someMethodWithLotsOfArguments(int thisIsValue1, int thisIsValue2, int thisIsValue3,
int thisIsValue4asdfasdfasdfasdfasdf, Double thisIsValue, int thisIsValue6, int thisIsValue7) {
不会破坏参数名称中的参数类型的东西会很棒。
返回File > Settings > Editor > Code Style > Java > Wrapping and Braces
并将“ Method declaration parameters
设置为“ Wrap always
这样做,方法
public void someMethodWithLotsOfArguments(int thisIsValue1, int thisIsValue2, int thisIsValue3, int thisIsValue4asdfasdfasdfasdfasdf, Double thisIsValue, int thisIsValue6, int thisIsValue7) {
}
格式如下
public void someMethodWithLotsOfArguments(int thisIsValue1,
int thisIsValue2,
int thisIsValue3,
int thisIsValue4asdfasdfasdfasdfasdf,
Double thisIsValue,
int thisIsValue6,
int thisIsValue7) {
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.