elgoog
elgoog

Reputation: 509

Intellij Scala class definition formatting

How can I get Intellij format my Scala class definition like this:

sealed class Traffic(
    private[this] val javaTraffic: Traffic.JavaTraffic,
    private[this] val sanitizer: Sanitizer)
  extends Serializable with Logger {

Basically 4 indents for member declaration on each line, and 2 indents for class inheritance.

Upvotes: 12

Views: 753

Answers (1)

Vasiliy Ivashin
Vasiliy Ivashin

Reputation: 425

Starting from version 2016.2 this can be done by making the next changes from the default under Settings > Editor > Code Style > Scala:

  1. Uncheck Method declaration parameters > Align when multiline under Wrapping and Braces.
  2. Check Alternate indentation for constructor args and parameter declarations under Other and set it to 4.

Downside is that this applies not only to constructor parameters, but to normal method declarations as well, so you can't have method params aligned with opening parenthesis. But I guess we'll have to live with that.

Upvotes: 3

Related Questions