Search code examples
scalaintellij-ideacode-formatting

Is it possible to format the tuples aligned by arrows in IntellIJ for scala?


In PyCharm there is an option to align dict items on colon for Python:

dct = {
    'one'  : 1,
    'two'  : 2,
    'three': 3,
}

And I want a similar way to format the dict items on arrow for Scala in IntellIJ:

val map = Map(
    "one" -> 1,
    "two" -> 2,
    "three" -> 3
    )

Solution

  • You can use Scalafmt from Scalameta. It can be integrated with many IDEs such us Intellij and Visual Studio Code.

    Also there is an sbt plugin for scalameta that lets format the code or validate if the code is formatted (good for CI/CD)