radFormatter / docs / embarcadero style guide
Embarcadero style guide
radFormatter ships a built-in Embarcadero
profile that maps its settings to Embarcadero's official Delphi Object
Pascal Style Guide for RAD Studio. This page explains what that profile
does, which style-guide recommendations it enforces, and which ones fall
outside a formatter's scope.
Official style-guide references:
- Delphi Object Pascal Style Guide
- General Rules
- Source Code Files, Units and Their Structure
- White Space Usage
- Statements
- Type Declarations
Using the profile
Select it on the CLI:
> radFormatter -profile Embarcadero -w -d source -r
The profile is a complete starting point. To adjust any individual
setting, overlay your own JSON with -config — only the
keys you list change:
> radFormatter -profile Embarcadero -config team-overrides.json -w source/MyUnit.pas
The companion radFormatter.Embarcadero.json is the full
profile written out explicitly (equivalent to
-profile Embarcadero). To adopt it, either save it into your
project as radFormatter.json (the conventional active-config
name) or pass it directly:
> radFormatter -config radFormatter.Embarcadero.json -w -d source -r
Download radFormatter.Embarcadero.json
Embarcadero performs active formatting: it lowercases keywords,
normalizes spacing, reflows begin/end and control
bodies (lineBreaks.keepUser is false), and wraps
at a 160-column margin.See the configuration options reference for the meaning of every key.
Settings mapped to the style guide
| Style-guide recommendation | radFormatter (Embarcadero) setting |
|---|---|
| Use lowercase language keywords, reserved words, and compiler directives. | casing.keywords: "lower", casing.directives: "lower" |
| Keep identifiers in their intended Pascal casing. | casing.identifiers: "asis" (radFormatter never rewrites identifier casing) |
| Two spaces per indentation level; no tabs. | indent.size: 2, indent.style: "spaces" |
| Two-space continuation indent for wrapped statements/declarations. | indent.continuationSize: 2 |
| Keep compiler directives at the left margin. | indent.directives: "column0" |
Indent case labels relative to case, and case-arm bodies relative to the label; keep case's else with the labels. | indent.caseLabels: true, indent.caseContent: true, indent.caseElseAlignment: "withLabels" |
| Spaces around assignment and binary operators. | spacing.assignment: "both", spacing.aroundBinaryOperators: "yes" |
| A single space after commas, declaration colons, and semicolons; none before. | spacing.comma: "after", spacing.colon: "after", spacing.semicolon: "after" |
| No spaces just inside parentheses or brackets. | spacing.insideParens: "no", spacing.insideBrackets: "no" |
| No space between a routine name and its parameter parenthesis. | spacing.beforeParens: "no" |
| No space before an index/bounds bracket. | spacing.beforeBracket: "no" |
| No spaces inside generic angle brackets. | spacing.genericBrackets: "no" |
No spaces around the subrange operator .. | spacing.aroundRange: "no" |
| No space between a unary/prefix operator (or cast) and its operand. | spacing.aroundUnaryOperators: "no" |
Put begin and end on their own lines; give control-statement bodies their own line. | lineBreaks.beforeBegin: "yes", lineBreaks.afterBegin: true, lineBreaks.beforeSingleInstr: "yes" |
| Keep at most one statement on a line. | lineBreaks.lineAfterSemicolon: true |
Preserve the accepted else if same-line style. | lineBreaks.betweenElseAndIf: false |
One uses entry per line, following the lowercase uses keyword. | lineBreaks.usesMode: "onePerLine" |
| Avoid vertical alignment of declarations. | all alignment.* off |
| Separate major logical sections with a blank line, but no repeated blank lines. | output.maxEmptyLines: 1, output.emptyLines.aroundSections: 1, output.emptyLines.betweenDeclarations: 1, output.emptyLines.beforeTypeKeyword: 1, output.emptyLines.beforeVisibility: 0 |
| Wrap long lines at a conventional editor width. | output.rightMargin: 160 |
Handled automatically by the CST indent engine
Several style-guide layout rules need no option — the concrete-syntax indent engine produces them structurally:
- Unit-level keywords (
unit,uses,type,interface,implementation,initialization,finalization, and the finalend) stay at the left margin. - Block contents sit one level inside
begin/end, whilebegin/endthemselves stay at the enclosing depth. - Nested (local) routines are indented under their enclosing routine.
thenstays on the same line as theifcondition.
Not enforced by radFormatter
Semantic / organizational (out of scope for a layout formatter)
These are recommendations about what the code says, not how it is spaced, so radFormatter deliberately leaves them alone:
- Use descriptive names, Pascal casing, and no Hungarian notation.
- Use dotted unit scope names such as
System.SysUtils. - Put data types and symbols used by only one unit in the implementation section.
- Arrange class members by access section, then fields, methods, and properties.
- Prefer constants (or inline constants) for values that are never modified.
- Prefer inline variables for tightly scoped block-local variables.
- Avoid extra parentheses around simple
ifconditions. - Omit empty parentheses for parameterless routines unless required by the compiler.
Notes
casing.numbersis left"asis": the style guide does not mandate a hex or exponent letter case, so radFormatter preserves what you wrote.output.lineEndingis"auto"(the platform default line ending; CRLF on Windows). Set it to"crlf","lf", or"cr"if your project standardizes on one.- The profile leaves all
reshaping.*options off, so it will not force call arguments, enums, arrays, or inheritance lists onto separate lines. The 160-columnrightMarginstill wraps over-long lines at their natural break points.