I know if I do sbt scalafmt
it will run it on the entire project. How can I do this for a specific file?
sbt-scalafmt provides a scalafmtOnly
task for this. It's documented at https://scalameta.org/scalafmt/docs/installation.html#task-keys , where we see:
scalafmtOnly <file>...
: Format specified files listed
You could also, outside of sbt, use the scalafmt
command, which is installable via Coursier.
Scalafmt can be now be launched via scala-cli
, so you can also:
scala-cli format <file>...