Forrest logo
back to the scalafmt tool

scalafmt:tldr:5c3ad

scalafmt: Format only files that were edited against the current Git branch.
$ scalafmt --config ${path-to--scalafmt-conf} --mode diff
try on your machine

The command scalafmt is used to format Scala code according to a specified configuration.

Here is an explanation of each part of the command:

  • --config ${path-to--scalafmt-conf}: This flag specifies the path to the scalafmt configuration file (usually named .scalafmt.conf). The configuration file defines the formatting rules to be applied to the Scala code. This flag is optional, and if it is not provided, scalafmt will search for a configuration file in the current directory and its parents.

  • --mode diff: This flag specifies the mode in which scalafmt operates. The diff mode is used to only format the changes made to the Scala code since the last formatting. It avoids reformatting the whole codebase and only applies the necessary changes to ensure consistent formatting.

Overall, the command scalafmt --config ${path-to--scalafmt-conf} --mode diff will format the changes made to the Scala code according to the specified scalafmt configuration file.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the scalafmt tool