Salil Surendran
Salil Surendran

Reputation: 2335

Formatting Scala code in IntelliJ

I have Scala code like this:

def myMethod(myInt: Int, myFloat: Float, myString: String): Unit = {
     //method body
}

I want to format it exactly like this:

 def myMethod(
     myInt: Int,
     myFloat: Float, 
     myString: String): Unit = {
     //method body
    }

So the caveat is that each parameter has to be in it's own line and needs to indented by 4 spaces. I have tried the Settings > Editor > Code Style > Java, under the "Wrapping and Braces" tab, and selected the "Wrap always" option for "Method declaration parameters". But that doesn't indent the code correctly. Anyway to do this?

Upvotes: 1

Views: 4191

Answers (1)

Joseph Guan
Joseph Guan

Reputation: 106

I think you should set for Scala but not Java: Settings > Editor > Code Style > Scala, Wrapping and Braces > Method declaration parameters. Select the "Wrap always".

It works for me. enter image description here

Upvotes: 3

Related Questions