IntelliJ IDEA 2026.2 Help

Scalafmt formatter

Instead of the default IntelliJ IDEA formatter, you can enable the Scalafmt formatter in your project.

Configure Scalafmt

Enable the formatter

  1. In the Settings dialog (Ctrl+Alt+S) , go to Editor | Code Style | Scala.

  2. From the Formatter drop-down list, select Scalafmt.

    The list of tabs under the formatter field updates accordingly.

    Scalafmt settings

Scalafmt has the following formatting options:

  • Use IntelliJ formatter for code range formatting: this option is selected by default. When you reformat a code selection in the editor, it will be reformatted with the default IntelliJ IDEA formatter. The code selection formatting is also applied to code snippets generated with various actions and live templates. The Scalafmt formatter can only reformat the entire file.

  • Reformat on file save: if you select this option, IntelliJ IDEA reformats a file when you save it Ctrl+S, switch between the active editor and tool windows, or execute a run/debug configuration.

  • Configuration: if IntelliJ IDEA does not find the .scalafmt.conf file with the specified formatter version in your project, it uses the current default Scalafmt version. You can override the default version.

Override the Scalafmt version

  1. Create the .scalafmt.conf file in the root of your project. Right-click your project and select New | File.

    Scalafmt configuration file
  2. Open the configuration file in the editor and specify the Scalafmt version you want to use along with other formatting options.

  3. Access the Scala formatter settings. IntelliJ IDEA reflects your changes for Scalafmt under the Configuration option.

    Scalafmt settings with changed version

Reformat code with Scalafmt

Note that the Scalafmt formatter can be applied to the entire file only. If you need to reformat smaller code fragments, they will be reformatted by IntelliJ IDEA.

  1. Open the file you want to reformat in the editor.

  2. In the main menu, go to Code | Reformat File (Ctrl+Alt+Shift+L) and adjust the settings in the Reformat File dialog.

  3. Click Run.

    Reformat file dialog

Learn more from Reformat code.

16 June 2026