Nicholas DiPiazza Nicholas DiPiazza - 1 year ago 58
Java Question

Can you customize how IntelliJ does auto format line wrapping on method declarations and method calls?

In this



It shows you how to enable auto line wrapping in IntelliJ.

But can you customize it further?

For example, if you auto format this with a line wrap value of 120:

public void someMethodWithLotsOfArguments(int thisIsValue1, int thisIsValue2, int thisIsValue3, int thisIsValue4asdfasdfasdfasdfasdf, Double thisIsValue, int thisIsValue6, int thisIsValue7) {


It will become:

public void someMethodWithLotsOfArguments(int thisIsValue1, int thisIsValue2, int thisIsValue3, int
thisIsValue4asdfasdfasdfasdfasdf, Double thisIsValue, int thisIsValue6, int thisIsValue7) {


Is there a way to get it to be smarter about this and format it like:

public void someMethodWithLotsOfArguments(int thisIsValue1,
int thisIsValue2,
int thisIsValue3,
int thisIsValue4asdfasdfasdfasdfasdf,
int thisIsValue5,
int thisIsValue6,
int thisIsValue7) {


Or at the very least like:

public void someMethodWithLotsOfArguments(int thisIsValue1, int thisIsValue2, int thisIsValue3,
int thisIsValue4asdfasdfasdfasdfasdf, Double thisIsValue, int thisIsValue6, int thisIsValue7) {


Something that doesn't break up the parameter type from the parameter name would be great.

Answer Source

Go back in File > Settings > Editor > Code Style > Java > Wrapping and Braces

and set Method declaration parameters to Wrap always

Doing so, method

public void someMethodWithLotsOfArguments(int thisIsValue1, int thisIsValue2, int thisIsValue3, int thisIsValue4asdfasdfasdfasdfasdf, Double thisIsValue, int thisIsValue6, int thisIsValue7) {
}

Will be formated as following

public void someMethodWithLotsOfArguments(int thisIsValue1,
        int thisIsValue2,
        int thisIsValue3,
        int thisIsValue4asdfasdfasdfasdfasdf,
        Double thisIsValue,
        int thisIsValue6,
        int thisIsValue7) {
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download