Command Line Formatter
Command-line source code formatter is a special functionality within WebStorm that lets you format arbitrary files outside a project.
The script is format.bat/format.sh
located in the <WebStorm_HOME>/bin
home directory. The script launches WebStorm which formats the specified files and quits:
format [-h] [-r|-R] [-s|-settings settingsPath] [-m|-mask masks] [path1 [path2]...]
You can launch the script with the following options:
Parameter | Description |
---|---|
-h | Shows help and quits. |
-r|-R | Scans directories specified in path1,path2... recursively. |
-s|-settings settingsPath | settingsPath is a path to the file with the code style settings. You can use one of the following:
If this parameter is omitted, the default code style settings are used. |
-m|-mask masks | A comma-separated list of file masks which defines the files to be processed. Wildcards * (any string) and ? (any single character) are supported. |
pathN | The path to a file or directory to be processed. |
Example
1. Format all files in C:\Data\src
directory including all subdirectories using the default code style settings:
format -r C:\Data\src
2. Non-recursively format all .java
and .html
files in the C:\Data\src
directory using code style settings from C:\Data\settings.xml
:
format -s C:\Data\settings.xml -m * .java,*.html C:\Data\src