Formatter Options

From RAD Studio
Jump to: navigation, search

Go Up to Language Options


Tools > Options > Language > Formatter

Pages in the Formatter group define the formatter options that customize the behavior of the source code formatter. When you select an option, help for the option is displayed in the lower pane of the page.

Note: C++ code formatting is perfomed through clang-format, and its options can be found at Tools > Options > Language > C++ > Formatting.

Delphi formatting options

Different sets of formatting options are used to format Delphi source code files:

  • In pages under Delphi, you can set options to be used in Delphi projects for Delphi source code files with the following extensions: *.pas, *.dpr, *.dpk, *.dpkw, *.inc.
Delphi contains the Indentation, Spaces, Line breaks, Capitalization, and Align pages.

Indentation

Indentation options Description

Continuation indent

Defines additional indent that is added for continuation lines when an expression is continued on several lines. The default is 2.

Do not indent after position

Defines the maximum width of indent, which the formatter can insert. The default is 40.

Indent assembly sections

If set to True indents assembly sections as usual code. The default is True.

Indent Begin and End keywords

If set to True indents the 'begin' and 'end' keywords. The default is False.

Indent blocks between Begin and End

If set to True indents block contents between 'begin' and 'end' keywords. The default is True.

Indent case contents

If set to True indents contents of case-statement blocks (after case labels( relatively to case labels. The default is True.

Indent case labels

If set to True indents case labels relatively to the 'case' keyword. The default is True.

Indent class definition bodies

If set to True inserts additional indent for sections in class definition bodies. Members before the first section are always indented. The default is False.

Indent comments

If set to Yes indents comments as usual statements. The default is Yes.

Indent compiler directives

If set to True indents compiler directives as usual statements. The default is False.

Indent Else in case statements

If set to True an extra indent 'else' in case statements. The default is False.

Indent function bodies

If set to True adds an indent function and procedure bodies. The default is False.

Indent inner functions

If set to True indents code of inner functions and procedures relatively to the code of the main function and procedure. The default is False

Indent interface, implementation, and other sections

If set to True adds indent section contents after 'interface', 'implementation', 'initialization' and 'finalization' keywords. The default is False.

Indent labels

Defines indentation of labels. The default is set to Decrease one indent.

Indent nested brackets and parentheses

If set to True, it inserts additional indent for continuation lines for each additional nesting level of [] brackets and () parentheses. The defualt is False.

Spaces

Space options Description

Resolve space conflicts as

Defines how to manage spaces in positions that are controlled by several conflicting options. The default is Space.

Set spacing around assignment operators

Defines space around assign '=' operators. The default is Before and after.

Set spacing around binary operators

Defines spaces around binary mathematical operators. The default is Before and after.

Set spacing around colons

Defines spaces around colons. The default is After only.

Set spacing around colons in format

Defines spaces around colons in format parameters. The default is None which does not insert spaces.

Set spacing around commas

Defines spaces around colons. The default is After only.

Set spacing around semicolons

Defines spaces around semicolons. The default is After only.

Set spacing around unary prefix operators

Defines spaces around unary prefix operators. The default is None.

Set spacing for // comments

Defines spaces around the // token in line comments. The default is Before and after.

Set spacing for { and (* comments

If set to True indents compiler directives as usual statements. The default is False.

Indent Else in case statements

Defines spaces around the opening, closing braces, or in block comments. The default is Inner and outer.

Set spacing for parentheses

If set to True inserts one space after each opening and before each closing parenthesis. The default is False.

Set spacing for square brackets

If set to True inserts one space after each opening and before each closing square bracket. The default is False

Set spacing inside angle bracket in generics

Defines inner spacing inside angle brackets used in generics to specify lists of type arguments. The default is False.

Space before parenthesis in functions

Defines spaces before parenthesis in functions and procedures. The default is set to No.


Line Break

Indentation options Description

Keep user line breaks

If True, keeps line breaks existing in the source code. Otherwise, if False ignores exisitng line breaks. The default is False.

Line break after Begin

Defines whether to insert a line break after each 'begin' keyboard. The default is Yes.

Line break after label

Defines whether to insert line breaks after labels. The default is Yes.

Line break characters

Defines characters that will be inserted as line breaks.

Line break inside 'Else If'

Defines whether to insert line breaks between 'else' and 'if' in nested 'if' statements. The default is False.

Line breaks after Begin in control statements

Defines whether to insert line breaks after 'begin' in conditional statements and in loop statements. The default is Yes.

Line breaks after Begin in method definitions

Defines whether to insert line breaks after the 'begin' keyword in method definitions. The default is Yes.

Line breaks after semicolons

Defines whether to insert a line break after each semicolon. The default is True.

Line breaks after Uses keywords

Defines whether to insert line breaks after Uses, Label, Export, Requires and Contains keywords. The default is As is.

Line breaks before Begin in control statements

Defines whether to insert line breaks before 'begin' in conditional statements and in loop statements. The default is Yes.

Line breaks before single instructions ion control statement

Defines whether to insert line breaks before single instructions in conditional statements and in loop statements. The default is Yes.

Line breaks before single instructions in try-except blocks

Defines whether to insert line breaks before single instructions in 'try-except' and 'try-finally' blocks. The default is Yes.

Line breaks before Then

Defines positioning of 'then' keywords in 'if' statements. The default is False.

Line breaks in Anonymous Function assignments

Defines whether to insert line break in assignment with Anonymous Function. The default is False.

Line breaks in Anonymous Function usage

Defines whether to insert line break in Anonymous Function usage. The default is True.

Line breaks in array initializations

Controls line breaks in array initializations. The default is Yes.

Line breaks in Inheritance lists

Defines positioning of base classes and interfaces in inheritance lists. The default is No.

Line breaks in Label, Export, Requires, Contains clauses

Defines whether to insert line breaks before the element in Label, Export, Requires, Contains clauses. The default is No.

Line breaks in Property declarations

Defines whether to insert line breaks before each 'read', 'write', 'stored', 'default' keyword inside property declarations. The default is False.

Line breaks in Uses clauses

Defines whether to insert line breaks before each element in the Uses clauses. The default is As is.

Line breaks in Var and Const sections

Defines whether to insert line breaks before each element in Var and Const sections. The default is Yes.

Max number of adjacent empty lines

Defines the maximum number of adjacent user-defined empty lines in the code. The default is 1.

New line for a function return type

Defines positioning of the return type in a function declaration and definition. The default is No.

Number of empty lines around compiler directives

Defines the number of empty lines used as separators around compiler directives. The default is 0.

Number of empty lines around section keywords

Defines the number of empty lines used as separators around 'Interface', 'Implementation', and other keywords that open sections. The default is 1.

Number of empty lines as separator in the implementation section

Defines the number of empty lines used as separators in implementation sections. The default is 1.

Number of empty lines as separator in the interface section

Defines the number of empty lines used as separators in interface sections. The default is 1.

Number of empty lines before subsections

Defines the number of empty lines used as separators before 'Var', 'Const' 'Label', and other subsections. The default is 1.

Number of empty lines before Type keyword

Defines the number of empty lines used as separators before 'type' keywords. The default is 1.

Number of empty lines before visibility modifiers

Defines the number of empty lines used as separators before visibility modifiers. The default is 0.

One parameter per line in function calls

Defines positioning of parameter values in function/procedure calls. The default is No.

One parameter per line in function definitions

Defines positioning of parameters in function and procedure declarations and definitions. The default is No.

Remove line breaks inside 'End Else Begin'

Defines whether to remove line breaks inside 'End Else Begin' constructions. The default is False.

Remove line breaks inside 'End Else If'

Defines whether to remove line breaks inside 'End Else If' constructions. The default is False.

Right margin

Defines the right margin to split code lines. The default is 80.

Trim source

Controls removing white spaces (spaces, tabs, and line breaks) from the beginning and end of the file. The default is True.

Capitalization

Indentation options Description

Capitalization of compiler directives

Defines capitalization of compiler directives. The default is UPPER CASE.

Capitalization of numbers

Defines capitalization of letters uses in hexadecimal and float numbers, including characters in prefixes and suffixes. The default is UPPER CASE.

Capitalization of other words

Defines how to capitalize words that do not belong. The default is As first ocurrence.

Capitalization of reserved words and directives

Defines capitalization of reserved words and directives. The default is As is.

Align

Indentation options Description

Align ":" before type names

Defines whether to align colons before type names. The default is False.

Align "=" in constants

Align assigment operators in constant initializations. The default is False.

Align "=" in initializations

Align assigment operators in initializations . The default is False.

Align "=" in type declarations

Align "=" in type declarations. The default is False.

Align assignment operators

Align assigment operators. The default is False.

Align end-of-line comments

Align comments located at the ends of lines. The default is False.

Align fields in properties

Align fields and methods in properties. The default is False.

Align type names

Align type names in var sections and records. The default is False.

Align types of parameters

Align types of parameters. The default is False.

Alignment maximum column

Do not insert alignment blank spaces after the specified column. The default is 60.

Maximum unaligned lines

The maximum number of consistent unaligned lines of code allowed without ending one alignment block of lines. The default is False.

Profiles and Status page

In the Profiles and Status page, you can manage sets of formatter options, enable the source code formatter, and enable the Confirmation prompting message before the formatting commands.

Managing sets of Formatter options

The source code formatter has several predefined sets of formatting options. You can select the active set with Select profile. Then the set of formatting options stored in the selected formatter profile (configuration file) becomes the currently used set of options for the formatter.

You can customize the active set of options and save it in a formatter configuration file using Save As. Later you can load the set of options (stored in a configuration file) using Load.

Managing Formatter's behavior

Options in the Formatter Status group define the formatter behavior:

  • Enable Formatter -- Select this option to enable the formatter. If this option is unselected, then all menu commands responsible for the formatting of source code files become hidden and inaccessible.
  • Show Confirmation dialog box -- When selected, the Confirmation prompting message appears each time you try to activate any formatting command.

Editor options used by Formatter

The source code formatter uses the Use tab character, Block indent, and Tab stops options that are defined in the Source Options page (Editor Options > Source Options) of the Options dialog box.

  • To set these options for Delphi, select Pascal in Source file type.
  • To set these options for C++, select C/C++ in Source file type.


See Also