0

In this answer

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.

Nicholas DiPiazza
  • 10,029
  • 11
  • 83
  • 152

1 Answers1

2

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) {
}
Thomas.L
  • 321
  • 1
  • 6