scalafmt icon indicating copy to clipboard operation
scalafmt copied to clipboard

Setting New line based on regex

Open devscheffer opened this issue 2 years ago • 1 comments

version = 3.5.8

Is there a setting so it configure new line based on regex or yhis symbol (&&, ||)?

What I have

val t = a == b && c == d

What I want

val t = 
  a == b 
    && c == d

devscheffer avatar Aug 11 '22 22:08 devscheffer

Thanks for reporting! Wouldn't it make it very easy to break your code? I would opt to keep the options more limited. Maybe https://scalameta.org/scalafmt/docs/configuration.html#newlinesafterinfixkeep would be useful to you?

tgodzik avatar Aug 12 '22 07:08 tgodzik

please reopen if the proposed parameter (keep or other values) is substantially insufficient, and there's a safe, dialect-compatible suggestion.

meanwhile, there's a parameter to induce a newline after val t = (forceAfterAssign or forceAfterMultilineAssign).

kitbellew avatar Aug 17 '22 16:08 kitbellew