pasfmt is a complete and opinionated formatter for Delphi code.
- Enforce a sensible, opinionated, and consistent formatting style.
- Format the entire file - none of the input code is left unformatted.
- Support all modern Delphi language features.
- Fast.
- Format invalid or incomplete code (within reason).
Try the web demo, download the latest release, or build from source.
To format one pas, dpr, or dpk file (in-place), run
pasfmt path/to/file.pasTo recursively format all supported files in a directory (in-place), run
pasfmt path/to/directory/To show all command-line options, run
pasfmt --helpSome aspects of formatting style can be controlled from a configuration file.
The full list of available options is here, and can also be printed from the command line by running pasfmt -C help.
To customise the configuration, create a file called pasfmt.toml in the root directory of the project
you are formatting. Make sure that pasfmt is being run from that directory, or a child directory.
For example:
# in a file called pasfmt.toml
# change the target line length
wrap_column = 100
# in most cases, it is not necessary to configure the encoding
encoding = "UTF-8"Specific pasfmt.toml files can also be used from the command-line:
pasfmt --config-file path/to/pasfmt.toml path/to/file.pasAdditionally, configuration options can be specified on the command-line, which will override values from the file:
pasfmt -C wrap_column=100If there are sections of code that you would rather the formatter skip over, you can temporarily disable formatting:
// pasfmt off
const ValueMap: TArray<Integer> = [
1, 2,
3, 4,
5, 6
];
// pasfmt onpasfmt-rad: a Delphi IDE extension forpasfmtpasfmt-action: a GitHub Action for integratingpasfmtinto GitHub CI workflows
- Install Rust (>= 1.82)
-
cargo build --release
This project is licensed under LGPL-3.0.