Code-formatting: How to align multiline code to special characters?

可紊 提交于 2019-12-03 03:05:36

You can align case statements, however:

value match {
  case s: String => Some(java.lang.Long.parseLong(s))
  case bi: BigInt => Some(bi.longValue)
  case _ => None
}

Like so:

value match {
  case s: String  => Some(java.lang.Long.parseLong(s))
  case bi: BigInt => Some(bi.longValue)
  case _          => None
}

Use option:

Settings -> Code Style -> Scala => Wrapping and Braces -> 'match' and 'case' statements -> Align in columns 'case' branches

In IDEA 12 if you're using the Scala plugin you can configure "Align when multiline" for many things, including method parenthesis. Your particular example of multiple invokations on separate lines is not supported however.

Code formatter seems to be a solution.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!