I am answering this question Q&A style.
- Go to
Tools
> Options
- Find the
Formatter
section in the tree on the left
- Inside that node, select
Delphi
> Line Breaks
- Locate the section on the right labeled
Insert line breaks for Begin and Single instructions
- Inside here, find the setting labeled
Line breaks before Begin in control statements
- Switch this setting between
Yes
or No
depending on your preference.
Yes
will produce this:
if (Foo = Bar) then
begin
end;
No
will produce this:
if (Foo = Bar) then begin
end;
By default, this setting is set to Yes
which means when you use Format Source
, it will always bring begin
to the next line.
There are many settings in this section which can define how Format Source
will treat your code. This option is available in at least RAD Studio 2010 and above. Not sure of which exact editions.
Note: Ctrl
+ D
is a keyboard shortcut to format your source, a quicker alternative.