How do I configure the RAD Studio IDE to format my code with begin on either the same or next line when I use the Format Source option?
One of the most commonly debated preferences is the position of begin – on the same line or a line of its own. How do you set Delphi to format your source with begin on one line or the other in Delphi XE2? This is referring to when you go to Edit > Format Source
I am answering this question Q&A style.
Tools>OptionsFormattersection in the tree on the leftDelphi>Line BreaksInsert line breaks for Begin and Single instructionsLine breaks before Begin in control statementsYesorNodepending on your preference.Yeswill produce this:Nowill produce this:By default, this setting is set to
Yeswhich means when you useFormat Source, it will always bringbeginto the next line.There are many settings in this section which can define how
Format Sourcewill treat your code. This option is available in at least RAD Studio 2010 and above. Not sure of which exact editions.Note:
Ctrl+Dis a keyboard shortcut to format your source, a quicker alternative.