Home > OS >  How to set the IntellIJ's scala format for if statement?
How to set the IntellIJ's scala format for if statement?

Time:09-28

I am using IntelliJ IDEA 2022.2.2 (Community Edition, Build #IC-222.4167.29) with Scala plugin 2022.2.677. I want the scala if statement with following style:

class test {
    def ifelse(i: Int): String =
        if i == 1 then "one"
        else if i == 2 then "two"
        else if i == 3 then "three"
        else "many"
}

But it was formatted by IDEAIJ as following:

class test {
    def ifelse(i: Int): String =
        if i == 1 then "one"
        else if i == 2 then "two"
             else if i == 3 then "three"
                  else "many"
}

I can not found an option to change this.

CodePudding user response:

Try to disable the option Align if-else statements under Settings/Preferences | Editor | Code Style | Scala | Wrapping and Braces | if() statement

  • Related