27

Are there any utilities that reformat Delphi code ?

EDIT

I am using Delphi 2006

Some feedback

Thanks to all that answered this question

I have been using the JCF code formatter - it works well and my code is been formated to Object Pascal Style Guide

Bruce McGee
  • 15,076
  • 6
  • 55
  • 70
Charles Faiga
  • 11,665
  • 25
  • 102
  • 139

11 Answers11

30

You can try the "Jedi code Format". See more information here: http://jedicodeformat.sourceforge.net/

The formatting engine of DelForExp has been integrated into the code base of GExperts. An experimental version of GExperts including a "Code formatter" here:
http://blog.dummzeuch.de/experimental-gexperts-version/

Separate information/downloads for DelForExp here.

Regards.

Jan Doggen
  • 8,799
  • 13
  • 70
  • 144
22

I have been for some time releasing experimental GExperts versions that include the code formatter formerly known as DelForEx with some improvements and fixes. The latest release is from 2020-10-23 and supports the following Delphi versions:

  • Delphi 6 to 7
  • Delphi 2005 to 2010
  • Delphi XE
  • Delphi XE2 to XE8
  • Delphi 10 to 10.4
  • Delphi 11 (Danger, Alpha version for now 2021-10-24)

Please note, though, that I am using it only with Delphi 2007, so the other versions may have unknown bugs. Also, not all language improvements of later Delphi versions will work, e.g. nested types, generics and anonymous methods.

see gexperts.dummzeuch.de for details.

btw: Any help improving the formatter, especially adding the new language constructs would be appreciated. The source code can be downloaded from the subversion repository linked from my homepage.

dummzeuch
  • 10,975
  • 4
  • 51
  • 158
5

I found this: JEDI Code Format

PEZ
  • 16,821
  • 7
  • 45
  • 66
4

lextudio - Code Beautifier Collection 6 for CodeGear RAD Studio 2007

http://code.google.com/p/lextudio/

RRUZ
  • 134,889
  • 20
  • 356
  • 483
3

BTW: There is an integrated Source Code Formatter since Delphi 2010.

splash
  • 13,037
  • 1
  • 44
  • 67
3

Yes,

I always used TWM's experimental version os GExperts which support this feature.

In Delphi 2006 and 2007 it works perfectly (Don't know about older versions though).

The current version is adding support to Delphi 2009, but I don't know in which stage it is, you can find more about it here:

http://www.dummzeuch.de/delphi/gexperts/english.html

Fabio Gomes
  • 5,914
  • 11
  • 61
  • 77
2

Free Pascal also has a codeformatter, ptop, but it only implements the more basic dialect (say D4-D6 level).

Lazarus recently changed to use the Jedi codeformatter afaik.

Marco van de Voort
  • 25,628
  • 5
  • 56
  • 89
1

The TWM version of GExperts works well and is nicely integrated into the IDE. It enables you to write and modify your code without worrying too much about exact formatting, then just hit the assigned hot-key and it instantly reformats. I have always found it easy to set up to match the style I prefer, and not as complex as JEDI Code Format, which looked like overkill to me.

The Delphi 2009 version is now available from the link posted above, though based on a beta release of GExperts. It is still much the same formatter underneath, though, and is unaware of the syntax of some of the newer Delphi enhancements.

frogb
  • 2,040
  • 15
  • 22
1

I just made an online pascal code beautifier based on JCF. You may try it at https://pak.lebah.web.id/jcf

HTH.

Bee Jay
  • 183
  • 2
  • 10
0

There is OPEdit II which is free, and works very well. It's a full text editor, with code refactoring and code browsing. There is a text formatter, which uses the internal code parser, therefore handle conditional defines just as a real Delphi compiler. See http://www.codefactor2.com

A.Bouchez
  • 386
  • 2
  • 4
0

There is a program PascalFormat enter image description here

Alex78191
  • 2,383
  • 2
  • 17
  • 24