Skip to content

RADProgrammer Style Guide LineBreaks

Darian Miller edited this page Mar 14, 2021 · 1 revision

Settings for: Line Breaks

Note: RADProgrammer utilizes non-default settings for:

  • Right margin
  • Line breaks in Anonymous Function assignments
  • Line breaks in array initializations
  • Line breaks in Uses clauses
  • Max number of adjacent empty lines
  • Number of empty lines as separator in implementation section
  • Number of empty lines as separator in interface section
  • Number of empty lines before subsections

General

  • Keep User Line breaks: False

    • True - keep line breaks existing in source code
    • False - ignore existing line breaks (Default)
  • Line break characters: Default value of the system Note: This only works for the stand-alone formatter The IDE always uses the Default value of the system

    • Default value of the system (Default)
    • Windows use \r,\n
    • Unix use \n
    • Mac use \r
  • Right margin: 240 Defines the right margin to split long code lines

    • Default is 80
  • Trim source: True Remove any whitespace from end of line and end of file (spaces, tabs and line breaks) Note: The integrated formatter always removes any white space from the end of the file Both the IDE and stand-alone formatter adds one empty line at the end of the saved file

    • Default is True

Insert line breaks

  • Line break after label: Yes

    • Yes - insert line breaks (Default)
    • No - do not insert line breaks
    • As is - preserve line breaks in the source code
  • Line break inside "Else if": False Defines whether to insert lines between else and if in nested if statements

  // "True" example

  if condition1 then
    operation1
  else
  if condition2 then
    operation2;

  // "False" example (Default)

  if condition1 then
    operation1
  else if condition2 then
    operation2;
  • Line break inside semicolons: True Note: line breaks are always added before/after the most significant statements: class definitions and declarations, method definitions and declarations, loops, control statements and others Note: line breaks are not added after internal semicolons inside declarations, definitions, etc. such as function f(l:integer):integer; virtual; abstract;

    • True insert a line break after semicolons ; before a new statement (Default)
  • Line breaks after Uses keywords: As Is Defines whether to insert line breaks after Uses, Export, Requires, and Contains keywords See also: "Line breaks in Label, Export, Requires, Contains clauses" and "Line breaks in Uses clauses"

    • Yes - insert line breaks
    • No - do not insert line breaks
    • As is - preserve line breaks in the source code (Default)
  • Line breaks before "Then": False

  // "True" example

  if condition1
  then
    operation1

  // "False" example (Default)

  if condition1 then
    operation1
  • Line breaks in Anonymous Function assignments: True
  // "True" example

  func :=
    function(x:integer):integer
    begin
      Result := x + y;
    end;

  // "False" example (Default)

  func := function(x:integer):integer
    begin
      Result := x + y;
    end;
  • Line breaks in Anonymous Function usage: True
  // "True" example (Default)

  if EnumerateFiles(10,
    function(Filename:string):boolean
    begin
      Result := True;
    end) then
      WriteLn('test');

  // "False" example

  if EnumerateFiles(10, function(Filename:string):boolean
    begin
      Result := True;
    end) then
      WriteLn('test');
  • Line breaks in array initializations: As is
  // "Yes" example (Default)

  LangStrings : array[0..5] of string (
    UK,
    FR,
    JP
  );

  // "No" example

  LangStrings : array[0..5] of string (UK, FR, JP );

  // "As-is" example

  LangStrings : array[0..5] of string (UK, FR,
    JP );

  // "Only first dimension" example

  ArrayStates: array[0..1, 0..1] of string = (
    ('AL', 'Alabama'),
    ('AK', 'Alaska')
  );
  • Line breaks in Inheritance lists: No Defines positioning of base classes and interfaces in inheritance lists
  // "No" example (Default)

  TnxBase = class(TnxDataAccess, IUnknown, InxSession)

  // "Yes, first name on the same line" example

  TnxBase = class(TnxDataAccess,
                  IUnknown,
                  InxSession)

  // "Yes, first name on the next line" example

  TnxBase = class(
    TnxDataAccess,
    IUnknown,
    InxSession)

  // "As is" example
  // Preserves positioning of base classes on separate lines in the source code

  TnxBase = class(TnxDataAccess, IUnknown,
    InxSession)
  • Line breaks in Label, Export, Requires, Contains clauses: As Is See also: "Line breaks after Uses keywords" and "Line breaks in Uses clauses"
    • Yes - insert line breaks
    • No - do not insert line breaks
    • As is - preserve line breaks in the source code (Default)
  • Line breaks in Property declarations: False Defines whether to insert a line break before each read, write, stored, default keyword inside property declarations
  // "True" example

  property CustomStrings:TStrings
    read diGetCustomStrings
    write diSetCustomStrings
    stored diCustomStringsStored;

  // "False" example (Default)

  property CustomStrings:TStrings read diGetCustomStrings
    write diSetCustomStrings stored diCustomStringsStored;
  • Line breaks in Uses clauses: Yes See also: "Line breaks after Uses keywords"
    • Yes - place each element on a new line
    • No - place all elements on the same line (if possible)
    • As Is - preserve line breaks as in the source code (Default)
  • Line breaks in Var and Const sections: Yes
    • Yes - place each element on a new line (Default)
    • No - place all elements on the same line (if possible)
    • As Is - preserve line breaks as in the source code
  • Remove line breaks inside "End Else Begin: False
  // "True" example
  // Remove all line breaks

  if True then begin
    a := 1
  end else begin
    a := 2
  end;

  // "False" example (Default)
  // Use line breaks as defined by other options

  if True then
  begin
    a := 1
  end
  else 
  begin
    a := 2
  end;
  • Remove line breaks inside "End Else If: False
  // "True" example
  // Remove all line breaks

  if True then
  begin
    a := 1
  end else if False then
    a := 2

  // "False" example (Default)
  // Use line breaks as defined by other options

  if True then
  begin
    a := 1
  end
  else if False then
    a := 2

Insert line breaks for Begin and Single instructions

  • Line break after Begin: Yes Note: This option manages situations that are not controlled by the "Line breaks after Begin in method definitions" and "Line breaks after Begin in control statements" options
    • Yes - insert a line breaks after "begin" (Default)
    • No - do not insert a line break after "begin"
    • As is - preserve line breaks in the source code
  • Line breaks after Begin in control statements: Yes Defines whether to insert line breaks after "begin" in conditional statements if-else or case and in loop statements while-do, for-do, with-do
    • Yes - insert a line breaks after "begin" (Default)
      if i > 10 then
      begin
        j := 3;
      end;
    • No - do not insert a line break after "begin"
      if i > 10 then
      begin j := 3;
      end;
    • As is - preserve line breaks in the source code
  • Line breaks after Begin in method definitions: Yes
    • Yes - insert a line breaks after "begin" (Default)
    • No - do not insert a line break after "begin"
    • As is - preserve line breaks in the source code
  • Line breaks before Begin in control statements: Yes Defines whether to insert line breaks before "begin" in conditional statements if-else or case and in loop statements while-do, for-do, with-do
    • Yes - insert a line breaks before "begin" (Default)
      if i > 10 then
      begin
        j := 3;
      end;
    • No - do not insert a line break before "begin"
      if i > 10 then begin
        j := 3;
      end;
    • As is - preserve line breaks in the source code
  • Line breaks before single instructions in control statements: Yes Defines whether to insert line breaks before single instructions in conditional statements if-else or case and in loop statements while-do, for-do, with-do
    • Yes - insert a line break (Default)
      if i > 10 then
        j := 3;
      else
        j := 1;
    • No - do not insert a line break
      if i > 10 then j := 3;
      else j := 1;
    • As is - preserve line breaks in the source code
  • Line breaks before single instructions in try-except blocks: Yes Defines whether to insert line breaks before single instructions in try-except and try-finally blocks
    • Yes - insert a line break (Default)
      try
        funct(10);
      except
        writeln('exception');
      end;
    • No - do not insert a line break
      try funct(10);
      except writeln('exception');
      end;
    • As is - preserve line breaks in the source code

Line breaks in functions

  • New line for a function return type: No Defines positioning of the return type in a function declaration and definition
    • Yes - place the return type on a new line
      function func1(i:integer)
        :integer;
    • No - place the return type on the same line as the function name (Default)
      function func1(i:integer):integer;
    • As is - preserve positioning of lines with return types in the source code
  • One parameter per line in function calls: No Note: This option only works if a function/procedure is called as a statement
    • Yes - place each parameter (if more than one) on a new line
      ret := function1(
               a,
               b,
               c);
    • No - place all parameters on the same line as the function name (Default)
      ret := function1(a, b, c);
    • As is - preserve positioning of lines with parameters in the source code
  • One parameter per line in function definitions: No
    • Yes - place each parameter (if more than one) on a new line
      function example1(
               a:integer,
               b:integer,
               c:integer):integer;
    • No - place all parameters on the same line as the function name (Default)
      function example1(a:integer; b:integer; c:integer):integer;
    • As is - preserve positioning of parameters on lines as in the source code

Number of empty lines

  • Max number of adjacent empty lines: 2 Defines the maximum number of adjacent user-defined empty lines in the code 0 - formatted source will contain only empty lines added by the formatter 1 - only one user-defined empty line will be preserved in the formatted code in each group of double (or more) empty lines (Default)
  • Number of empty lines around compiler directives: 0 Default of 0
  • Number of empty lines around section keywords: 1 Defines the number of empty lines used as separators around Interface, Implementation, and other keywords that open sections Default of 1
  • Number of empty lines as separator in implementation section: 2 Default of 1
  • Number of empty lines as separator in interface section: 2 Default of 1
  • Number of empty lines before subsections: 0 Defines the number of empty lines as separators before Var, Const, Label, and other subsections. Default of 1
  • Number of empty lines before Type keyword: 1 Default of 1
  • Number of empty lines before visibility modifiers: 0 Default of 0

Note: Configuration text reproduced directly from RAD Studio, Copyright (C) 2021 Embarcadero Technologies, Inc. No claim made of ownership made, reproduced here under Fair Use purposes only.