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

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Current »

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 idea.properties to some other file, for example, format.properties
  • Modify format.properties as follows:

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

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

    2. Change them to point to some directories which differ from defaults, for example:
      idea.config.path=${user.home}/.IntelliJIdea/format/config
      idea.system.path=${user.home}/.IntelliJIdea/format/system
              
  • Modify format.sh by adding the line with IDEA_PROPERTIES variable:
    #!/bin/sh
    # ------------------------------------------------------
    # IntelliJ IDEA formatting script.
    # ------------------------------------------------------
    
    IDE_BIN_HOME="${0%/*}"
    export IDEA_PROPERTIES=$IDE_BIN_HOME/format.properties
    exec "$IDE_BIN_HOME/idea.sh" format "$@"
        
  • Run format.sh 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.
        

     

  • No labels