Child pages
  • Command-Line Source Code Formatter
Skip to end of metadata
Go to start of metadata

Please check the official Command Line Formatter help page.

Running Command-Line Formatter when the IDE is Running

On Linux/MacOS

  • Go to <Intellij Home>/bin directory where <Intellij Home> is a directory where Intellij IDEA or Intellij IDEA-based product is installed.
  • Copy to some other file, for example,
  • Modify as follows:

    1. Uncomment the lines:
      # idea.config.path=${user.home}/.IntelliJIdea/config

      # idea.system.path=${user.home}/.IntelliJIdea/system

    2. Change them to point to some directories which differ from defaults, for example:
  • Modify by adding the line with IDEA_PROPERTIES variable:
    # ------------------------------------------------------
    # IntelliJ IDEA formatting script.
    # ------------------------------------------------------
    exec "$IDE_BIN_HOME/" format "$@"
  • Run without closing the IDE, it should give the following output:
    IntelliJ IDEA ..., build ... Formatter
    Usage: format [-h] [-r|-R] [-s|-settings settingsPath] path1 path2...
      -h|-help       Show a help message and exit.
      -s|-settings   A path to Intellij IDEA code style settings .xml file.
      -r|-R          Scan directories recursively.
      -m|-mask       A comma-separated list of file masks.
      path..         A path to a file or a directory.

On Windows

  • You have to create a separate file as described above for Linux/MacOS.
  • Change format.bat file by adding a line with IDEA_PROPERTIES variable as follows:
    :: IntelliJ IDEA formatting script.
    SET IDE_BIN_DIR=%~dp0
    CALL "%IDE_BIN_DIR%\idea.bat" format %*
  • Run format.bat, it will list the command-line formatter options.
  • No labels