score:7

scalafmt can do exactly this, and it is available as an idea plugin, and is packaged many other ways as well.

you want to use the align=more feature, as documented here. the docs show the following examples of alignment:

val x  = 2 // true for assignment
val xx = 22

case object b  extends a // false for `extends`
case object bb extends a

q  -> 22 // true for various infix operators
qq -> 3  // and also comments!

for {
  x  <- list(1) // true for alignment enumerator
  yy <- list(2)
} yield x ** xx

x match { // true for multiple tokens across multiple lines
  case 1  => 1  -> 2  // first
  case 11 => 11 -> 22 // second

  // a blank line separates alignment blocks.
  case `ignoreme` => 111 -> 222
}

// align assignments of similar type.
def name   = column[string]("name")
def status = column[int]("status")
val x      = 1
val xx     = 22

// align sbt module ids.
librarydependencies ++= seq(
  "org.scala-lang" % "scala-compiler" % scalaversion.value,
  "com.lihaoyi"    %% "sourcecode"    % "0.1.1"
)

Related Query

More Query from same tag