Go Up to Command-Line Utilities Index
Formatter.exe is the command line formatter for Delphi and C/C++ source code files.
Formatter.exe is the stand-alone application that does not require any supporting DLLs or other executable modules for its execution.
If a source code file cannot be compiled, then the formatting results can be incorrect.
Command line syntax
To display the short help, enter:
Formatter [-h]
To run the source code formatter from the command interpreter, use the following command line syntax:
Formatter [<options>] [<filename>...]
Command line options
You can use the following options:
Option
|
Description
|
-h
|
Use this option (or do not specify any options) to display the short help for the command line formatter.
|
-cpp
|
Format only files with the C/C++ predefined file name extensions (if other extensions are not specified by the filename options.)
The C/C++ predefined file name extensions:
*.cpp , *.cxx , *.cc , *.c , *.hpp , *.hxx , *.hh , *.h .
|
-delphi
|
Format only files with the Delphi predefined extensions (if other extensions are not specified by the filename options.)
The Delphi predefined file name extensions:
*.pas , *.dpr , *.dpk , *.dpkw , *.inc .
|
-config configfile
-config:configfile
|
configfile -- the configuration file name. Source files will be formatted according to the formatting options stored in configfile .
Configuration files can be created from the Profiles and Status page of the Options dialog box (Tools > Options > Formatter > Profiles and Status).
Defaults used in configfile :
- If
configfile does not specify a file name, then the formatter searches for the Formatter.config file.
- If you omit only the extension, then the
.config extension is accepted (if necessary).
- If
configfile is not a fully qualified file name, then the formatter searches for configfile in the following order:
- In the current directory.
- In the RAD Studio working directory, by default in
C:\Users\<username>\AppData\Roaming\Embarcadero\BDS\21.0 .
- In the RAD Studio installation directory, by default in
C:\Program Files (x86)\Embarcadero\Studio\21.0\bin\config .
|
-e encoding
-e:encoding
|
encoding defines the encoding for reading/writing. If omitted, then the formatter reads sources and tries to define the appropriate encoding automatically.
|
-d directory
-d:directory
|
directory defines the folder containing the files to format. If no filename is defined, then all files with both Delphi and C/C++ predefined extensions (or with the extensions defined by the -cpp or -delphi option, if specified) in the directory folder will be formatted.
|
-r
|
Format files recursively in the directory folder and in all its subdirectories.
|
-b
|
Create copies of files, with the appended .bak extension, before formatting.
|
-log logfile
-log:logfile
|
logfile defines the log file name into which the formatter writes its messages. By default, the formatter writes messages to the console.
|
-silent
|
Do not display error messages.
|
filename
|
filename specifies the name of a source file to format. The formatter writes the formatted source text into the same file.
You can specify several filename s separated by spaces. You can use the wild characters '*' and '?'.
If filename uses wild characters in the extension, then all files with both Delphi and C/C++ predefined extensions matched (or with the extensions matched to the -cpp or -delphi option, if specified) will be formatted.
To format a file with an extension that is not predefined, you should specify the language by using the -cpp or -delphi option.
|
See Also