Jump to content
Sign in to follow this  
dummzeuch

Delphi's code formatter vs. GExperts' code formatter

Recommended Posts

When I see formatting like this (generated by the Delphi formatter, if "Keep user line breaks" is turned on):

type
  TSomeRecord = record
    a,
      b, { bla }
    c,
      d: integer;
  end;

I wonder whether the Delphi formatter is based on DelForExp like GExperts'. But in the latter this bug has been fixed:

type
  TSomeRecord = record
    a,
      b, { bla }
      c,
      d: integer;
  end;

 

On the other hand, this is an interesting formatting:

type
  TSomeRecord = record
    a, b, // bla
    c, d: integer;
  end;

This was generated by the Delphi formatter from this input, with the default setting "Keep user line breaks" turned off:

type
  TSomeRecord = record
    a,
    b, // bla
    c,
      d: integer;
  end;

It would never have occurred to me.

Share this post


Link to post

I often use this double slash comments at the end of a line to force a line break.

const
  cArr: TArray<string> = [ //
    'SELECT *',            //
    'FROM EMPLOYEE',       //
    'WHERE EMP_NO > 2',    //
    'ORDER BY EMP_NO',     //
    ''];

(Align line end comments is active here)

 

Without these comments the formatter will produce this:

const
  cArr: TArray<string> = ['SELECT *', 'FROM EMPLOYEE', 'WHERE EMP_NO > 2', 'ORDER BY EMP_NO', ''];

 

Share this post


Link to post
21 hours ago, dummzeuch said:

I wonder whether the Delphi formatter is based on DelForExp like GExperts'. But in the latter this bug has been fixed:


type
  TSomeRecord = record
    a,
      b, { bla }
      c,
      d: integer;
  end;

Isn't it a bug as well? b-c-d should go right below a

Share this post


Link to post
1 hour ago, Fr0sT.Brutal said:

Isn't it a bug as well? b-c-d should go right below a

Not sure about that. I have seen that kind of formatting with the additional indentation for the second and later field very often. Personally I prefer explicitly giving the type for each field:

type
  TSomeRecord = record
    a: integer;
    b: integer; { bla }
    c: integer;
    d: integer;
  end;

even if that means a bit more typing.

Share this post


Link to post
1 hour ago, limelect said:

What I liked very much with DelForExp that you

could format the whole project.

The Delphi integrated formatter offers that as well.

  • Like 1

Share this post


Link to post

@Uwe Raabe The only thing that I dislike is that the Formater options are all over.

when you triggered  DelForExp it opens a form asking what you want to do

much simpler and more user friendly.  Or am I old fashion?

 

P.S I also have it as a stand-alone

 

Edited by limelect

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×