Search code examples
delphidelphi-2010formatter

Delphi 2010 Leave My Comments Alone


The code formatter in Delphi 2010 is a useful tool for developing coding standards, or at least this is my opinion, however it has a horrid habit of ruining comments.

A nicly commented block like this..

SomeFunction(SomeVaribleWithALongName,             // Comment
             Option2,                              // Comment
             FieldByName('SomeField').AsSomething; // Comment

Becomes harder to read

SomeFunction(SomeVaribleWithALongName, // Comment
             Option2, // Comment
             FieldByName('SomeField').AsSomething; // Comment

I have set everything I can see to either False, As Is or None, yet CTRL + D still moves my poor comments.

Does anyone have a solution to this or shall I just join the vast group of disappointed Delphi programmers that hate the Formatter?


Solution

  • Why don't you give GExperts a go (www.gexperts.org). There is an "experimental" version which is a patch on the latest version which is 1.33 which includes a code formatter. This code formatter was originally a separate tool called DelForEx which had been an excellent formatter since the early days of Delphi. The code formatter in GExperts has an option which allows you to align simple comments to a specific column position.

    GExperts is available for D2010. You need to first install the latest version and then copy the relevant files from the patch to add the code formatter. Even though the patch is labelled experimental it is pretty stable so I wouldn't worry about that too much.