Formatting Files from Command Line
Command-line source code formatter is a special functionality within DataGrip that lets you format arbitrary files outside a project.
- In the command line, run
format
command the using the following syntax:format [-h] [-r|-R] [-s|-settings settingsPath] [-m|-mask masks] path1 [path2...]The command launches DataGrip, which formats the specified files and then quits.
The command options are as follows:
Examples
Format all files in the C:\Data\src directory including all subdirectories using the default code style settings:
<IDE_HOME>\bin\format.bat -r C:\Data\srcNon-recursively format all the .xml and .html files in the C:\Data\src directory using code style settings from C:\Data\settings.xml:
<IDE_HOME>\bin\format.bat -s C:\Data\settings.xml -m * .xml,*.html C:\Data\src
Format all files in the ~/MyProject/src directory including all subdirectories using the default code style settings:
<IDE_HOME>/bin/format.sh -r ~/MyProject/srcNon-recursively format all the .xml and .html files in the ~/MyProject/src directory using code style settings from ~/Data/settings.xml:
<IDE_HOME>/bin/format.sh -s ~/Data/settings.xml -m * .xml,*.html ~/MyProject/src