scalafmt
Opinionated Scala code formatter
TLDR
Format files
SYNOPSIS
scalafmt [-i] [--check] [-c config] [options] [files]
DESCRIPTION
scalafmt is an opinionated code formatter for Scala that enforces consistent style across projects. It reformats source code according to configurable rules covering line length, indentation, alignment, and import ordering, supporting both Scala 2 and Scala 3 syntax through dialect configuration.
The --check mode verifies formatting without modifying files, returning a non-zero exit code when changes would be made, which is useful for CI pipeline enforcement. The -i (in-place) mode directly modifies files during development. Configuration is defined in a .scalafmt.conf file at the project root using HOCON format.
PARAMETERS
-i, --inplace
Modify files in place.--check
Check only, no changes.-c, --config FILE
Config file.--diff
Show changes.--stdin
Read from stdin.--stdout
Write to stdout.--exclude PATTERN
Exclude files.--help
Show help.
CONFIGURATION
.scalafmt.conf
Project-level configuration file in HOCON format defining formatting rules including maxColumn, dialect, align settings, and rewrite rules.
CAVEATS
May change code structure subtly. Configuration options are many. Editor integration recommended.
HISTORY
scalafmt was created by Olafur Pall Geirsson for Scala formatting. It's widely used in the Scala ecosystem for code style enforcement.
