Forrest logo
tool overview
On this page you find all important commands for the CLI tool scalafmt. If the command you are looking for is missing please ask our AI.

scalafmt

Scalafmt is a command-line tool used for formatting Scala code. It aims to provide a consistent and opinionated code style across different Scala projects.

  1. Scalafmt uses a default formatting style, but it also allows customization through configuration files.
  2. It can handle different code formats, including .scala files and even Scala code embedded in .md or .html files.
  3. The tool supports formatting scenarios like indentation, line wrapping, blank lines, and more.
  4. Scalafmt can preserve some manual formatting to maintain user preferences while ensuring consistent formatting for the remaining code.
  5. It supports various customization options, allowing project-specific formatting rules to be enforced.
  6. The tool has integrations with popular Scala editors and build tools like IntelliJ IDEA, sbt, and Maven.
  7. Scalafmt can be executed as a command-line tool, making it easy to incorporate into automated build processes or code review workflows.
  8. The formatting process is fast, thanks to its incremental algorithm that only formats the modified code instead of reformatting the entire file.
  9. Scalafmt is actively maintained and frequently updated to support the latest Scala language features and keep up with the community's evolving coding standards.
  10. The project is open source, allowing developers to contribute to its development or tailor the tool to their specific needs.

List of commands for scalafmt:

  • scalafmt:tldr:003a2 scalafmt: Reformat specific files or directories with a custom formatting configuration.
    $ scalafmt --config ${path-to--scalafmt-conf} ${filename_or_directory} ${filename_or_directory} ${---}
    try on your machine
    explain this command
  • scalafmt:tldr:24d0d scalafmt: Check if files are correctly formatted, returning `0` if all files respect the formatting style.
    $ scalafmt --config ${path-to--scalafmt-conf} --test
    try on your machine
    explain this command
  • scalafmt:tldr:5b819 scalafmt: Exclude files or directories.
    $ scalafmt --exclude ${filename_or_directory} ${---}
    try on your machine
    explain this command
  • 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
    explain this command
  • scalafmt:tldr:6a240 scalafmt: Reformat all `.scala` files in the current directory recursively.
    $ scalafmt
    try on your machine
    explain this command
tool overview