Search code examples
delphicode-formattingdelphi-xe8

How to make RAD Studio format case statements appropriately?


This is a follow-up to a prior question I asked a while back.

To summarize, I prefer to have begin statements show on the same line, rather than the next line. However, as a result of this, case statements do not format very friendly with the default settings:

case SomeEnum of
  seOne: begin

    end;
  seTwo: begin

    end;
  seThree:
    ;
  seFour:
    DoSomething;
end;

I'm trying to figure out how to make it format like so instead:

case SomeEnum of
  seOne: begin

  end;
  seTwo: begin

  end;
  seThree: ;
  seFour: DoSomething;
end;

However, I cannot find the appropriate options to make this change.

How do I make case statements format as shown above?


Solution

  • Your current setup needs two modifications. Set "indent case contents" to false in "indentation" options and "line breaks before single instructions in control statements" to 'no' in "line breaks" options.