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"
)
Source: stackoverflow.com
Related Query
- How to exclude scala formatting for html files using vs code
- How to map an Option inside a for comprehension with EitherT
- How to convert this map/flatMap into a for comprehension in Scala?
- How do you impose scala code coverage specifically for integration tests?
- Code-formatting: How to align multiline code to special characters?
- scala's for yield comprehension used with Future. How to wait until future has returned?
- How to use an autoincrement index in for comprehension in Scala
- How to configure code style for Scala in IntelliJ IDEA
- How to custom code folding for Scala in intelliJ IDEA?
- why can't I extract a tuple from Either projection inside for comprehension using pattern matching?
- How to organize code for multiple scala versions and differents dependencies
- How do you indent code block for scaladoc
- How to write for comprehension in cats with IO monad
- scala: how to rewrite this function using for comprehension
- In scala, how to generate boilerplate code for parameter list of different length?
- How to turn this for comprehension into a flatMap implementation
- Behaviour of Options inside for comprehension is Scala
- How to filter requests for access code in Play 2.1
- How to convert this map/flatMap into a for comprehension in Clojure?
- How to pattern match on multiple things in a for comprehension
- Code-formatting: How to align <- inside for-comprehension?
- How do I flatten a nested For Comprehension that uses I/O?
- How can I view the code that Scala uses to automatically generate the apply function for case classes?
- How to merge two types of for comprehension in Scala?
- How to load a class from the source code using reflection inside SBT task?
- How to make following code run for large values of `n` while maintaining the functional style in Scala?
- How use for comprehension in Scala with unknown collections?
- How to count the number of iterations in a for comprehension in Scala?
- Online Tool For Formatting Scala Code
- Counter inside of scala for comprehension
More Query from same tag
- How to poll with a Future in Scala?
- Anonymous function as argument in scala
- Scala with play: Class Cast Exception when trying to send data through a websocket
- What should I import for Scalaz' traverse functionalities
- Uisng Hive Context , Creating Hive Table locally in local system metastore_db instead on Cluster, where to place my hive-site.xml
- Apache Curator TestingServer creation throws java.lang.NoSuchMethodError
- Scala extract the parameter in for comprehension when match multiple cases classes
- how to make combination of values in a string using scala?
- Why does this akka-http route test never complete successfully?
- Better way to handle errors with Monix Observable
- What would be an efficient way to merge those lists?
- Play Framework + JDBC + Futures
- Read the text content in a XML file
- Why is f-bounded polymorphism im Scala commonly implemented with an upper type bound as well as a self type
- How to pattern match all classes with context bound
- Scala: Implicit evidence of Map with Traversable values?
- Returning multiple collections from flatMap
- Spark PCA OutOfMemory error on small number of columns and rows
- Play! Internationalization of template parameter
- Calculate Cosine Similarity Spark Dataframe
- Scala empty a list
- How to reference the result of reduce() operation in Java 8?
- How can I output localized Java floating point values in full precision?
- how to create multiple chatrooms using websockets in scala?
- How can I get Syslogging to work on the JVM?
- Spark 2 sbt assembly deduplicate error Scala 2.11.8
- Will calling dataframe.distinct() result in shuffling the contents to the driver for a final distinction?
- Error handling in play framework
- Polymorphism, Autoboxing, and Implicit Conversions
- Spark job slow on cluster than standalone