Skip to main content
Thoughts from David Cornelius

Category

horribly messy codeRAD Studio 13 was released today and has several much-anticipated features and wonderful enhancements. There have been many blog posts talking about them and I'm excited to start using them; but today, I want to share some tips on how to deal with a feature that was removed: code formatting.

The Problem

As with all advancing technology, some things get better and some things must get left behind. Starting with Delphi 12, the modeling features were moved to an optional add-on installation, and in Delphi 13, they're being removed entirely due to technical constraints. This eliminates the built-in code formatter that many developers relied on for consistent code styling. A recommended replacement module for the refactoring capabilities is the well-supported MMX Code Explorer IDE plug-in. It does a great job but does not currently support code formatting. One suggestion is to use pasfmt, an open-source code formatter for Delphi code, ironically written in Rust, not Delphi!

A Solution: formatter.exe

Fortunately, there's a workaround that leverages an existing tool in previous versions of RAD Studio. Formatter.exe is a command-line formatter for Delphi and C/C++ source code files that ships in older versions of RAD Studio's \bin folder. This standalone utility can format your code using predefined profiles created in earlier versions of the IDE.

Setting Up the Workaround

Step 1: Create a Formatter Profile

Use a prior version of Delphi (before Delphi 13) such as Delphi 11 or Delphi 12 that has formatting options available and perform the following steps:

  • From the menu, select Tools → Options → Language → Formatter
  • Configure your preferred formatting settings (indentation, spaces, line breaks, etc.)
    Code Formatting options in Delphi 12
  • Once you are satisfied, go to the "Profiles and Status" section and click "Save As..." to save your settings to a file, typically with the pattern Formatter_*.config
  • The profile will be saved as an XML file in your user's roaming folder, typically at %AppData%\Embarcadero\BDS\[version]\Formatter.config; but you can change the location to something more suitable to your programming environment.

Step 2: Call formatter.exe

To format a source file, run the formatter from command line:

formatter.exe -config "path\to\your\profile.config" -delphi "source_file.pas"

This will modify that file so it would be wise to make a backup first. Of course, if you use version control, you could simply revert to a previous version of the file if something goes awry.

Now, you might think this is a little cumbersome, a far cry from the simply hitting Ctrl+D (or whatever hotkey you had assigned for code formatting in your IDE). But there's a cool way of adding this right into Delphi itself.

Step 3: Add IDE Integration

The Delphi "Tools" menu has long had the capability to add links to additional external tools. But it's more than just launching an executable, you can pass in IDE macros as parameters to these tools; that's what makes this such a cool solution!

Here's how to call the formatter with the current code file open in your IDE's editor:

  • Go to Tools → Configure Tools
  • Add a new tool with the following:
    • Title: "Format Code"
    • Program: "C:\Program Files (x86)\Embarcadero\Studio\23.0\bin\Formatter.exe
    • Parameters: -config "C:\path\to\your\profile.config" -delphi "$EDNAME"

Since this is an external tool, it doesn't have access to the current file loaded in the editor, so be sure and save it first. After you run this (the black, command-prompt window will briefly flash as the formatter runs) and the editor regains focus, the IDE will notice the file was updated and show this warning:
code changed warning

This is to be expected, so simply click Yes and your editor will be refreshed with the formatted code.

Limitations

Note that if a source code file cannot be compiled, the formatting results may be incorrect. The formatter works best with syntactically correct code. Also, the Formatter tool does not come with Delphi 13 so you need to keep around your previous version of Delphi.

Alternative Solutions

There are other options that should be noted as well, in addition to pasfmt mentioned above:

  • GExperts is an awesome IDE plug-in that has many productivity-enhancing features, including its own code formatter. I have used this in earlier versions of Delphi that did not have a formatter built in.
  • JEDI Code Format: There's an old JEDI Code Format on SourceForge and a newer JCF Code Formatter on Github that may be good options--I have no experience with either of these.

Conclusion

While losing the built-in formatter is inconvenient, the external tool, formatter.exe, existing in previous versions of Delphi, is a great workaround and provides a bridge solution for teams wanting to maintain consistent code formatting in Delphi 13. Combined with tools like MMX Code Explorer for refactoring needs, developers can maintain productive workflows despite the modeling feature removal.

The key is to keep your older version of Delphi until there's a better, more official solution--or just use GExperts!


P.S. The code shown in the image at the top of this post is taken from an actual, compilable Delphi VCL program. It's a test program (written by Claude.ai) that counts the number of words entered in an edit box and displays the results in a memo!

DelphiCoder (not verified) Wed, 09/10/2025 - 14:51

There is also the $SAVE macro available which will save the currently active file in the code editor! So just add this before -config:"C:\path\to\your\profile.config" "$EDNAME" and you can't forget to save the before invoking the code formatter tool.

$SAVE -config:"C:\path\to\your\profile.config" "$EDNAME"

david Wed, 09/10/2025 - 15:09

Wow--that actually works! And prompts you, too!  Thanks for that tip!

Zdzichs (not verified) Wed, 09/10/2025 - 17:11

This is crazy unprofessional :( I lost over an hour trying to fix grayed refactor and format menus :( How on earth such creepy solution could pass the QA in corp like Emb? Thanks for your workaround anyway, but the issue is just sad :(

david Wed, 09/10/2025 - 18:06

In reply to by Zdzichs (not verified)

I agree that it seems weird to leave a disabled menu item if there's no functionality behind it. I think it has to do with the fact the IDE is used for both Delphi and C++Builder; perhaps the latter product uses that. Even then, I'd think the code wouldn't be that hard to completely remove it for Delphi if there's absolutely no code for it.  Maybe it can be used by plug-in writers? And they hope someone will hook up that menu?

Joseph (not verified) Sun, 09/14/2025 - 18:53

"While losing the built-in formatter is inconvenient" - it's beyond that; it's inexcusable. It's a part of the core functionality of the IDE. They're proving time and again now they do not have enough developers to progress the product and deal with its Greek-level technical debt. They simply can no longer support the product. C++Builder broke about two years ago and can only target Windows for the foreseeable future. They failed to meet the Android 64bit deadline and had to beg for an extension. They added type inference and code completion broke for two years. I could go on and on.

The product is clearly unsustainable at this point. The resources Idera/Embarcadero have allocated to it are insufficient to deliver a viable product (no, an IDE without code formatting is not acceptable as an IDE). 

Until the community stands up and says "This is UNACCEPTABLE and we're not paying for it", and until the apologists stop defending it, nothing will change. They've shipped a broken and incomplete product. Period. It's not "technical constraints" that's the problem... it's ancient code they never bothered to update and did not have enough time to replace before a mandatory shipping deadline. Remember what got Nick Hodges fired (the first time): telling the dev team to be careful about bugs because Embarcadero "will ship c**p". Well, they just shipped it again. A $99 JetBrains IDE has advanced code formatting, and they're not struggling to replace 32bit code either. To offer a $1600 IDE/compiler suite with missing code formatting is just absurd. To accept it like this is NORMAL is even more absurd. 

david Sun, 09/14/2025 - 22:04

In reply to by Joseph (not verified)

I can't argue it appears there are not enough developers to maintain a viable product such as this and that preparation for replacing this old code should've been put in place several versions ago. However, there are options. Options to use GExperts, leverage external formatters, stay with an older version, or move to a different product altogether. There are forces at play within the company for which we know nothing about which likely constrain the actions and voices of the developers within the company trying to make this work for everyone. The only thing we can do as customers is to look at the options and choose the one that makes the most sense for ourselves.

Michael Riley (not verified) Mon, 09/15/2025 - 14:46

In reply to by david

David, 

Thank you for this post and for all your contributions to the Delphi community.

"...or move to a different product altogether."

Regarding your comment about moving to a different product. I love the Pascal language. I fell in love with it from day on back in 1986. I have used Lazarus + Free Pascal Compiler in the past. I would love to switch 100% completely over to L+FPC. The challenge that prohibits me from switching to L+FPC is this: I cannot get L+FPC to run on a Windows machine and cross-compile a simple "Hello World" program that runs on both a Windows and macOS machine. 

I do my dev work on a Windows machine. With Delphi it is easy to target macOS, push a button, and see the single code base run on a macOS computer. If I could get the same thing to happen using L+FPC I would switch in a heartbeat. 

I reached out to Detlef Overbeek (Editor Blaise Pascal) magazine over a year about this issue. He and Alfred Glanzer the creator of FPCUP Deluxe put together a video that shows how to cross-compile L+FPC. Unfortunately they did not demonstrate how to cross-compile for the macOS but they talked about "how easy it would be to add". I still could not get it to work.

Video demonstration of using FPCUP Deluxe:
https://downloads.blaisepascal.eu/Alfred2.mp4

 

Cheers,

Michael

david Mon, 09/15/2025 - 16:02

In reply to by Michael Riley (not verified)

Yeah, not all options are viable. I last ran Lazarus several years ago when I converted a friend's Windows-based registration program to run under his Linux-based website. It took a lot of configuration and work to get it all installed with the right libraries and such for that particular distribution of Linux. I do so much work on Windows with Delphi, I don't have time to keep up with all the nuances of multiple environments. I'm sure L+FPC on Windows is much simpler; no idea how that would cross-compile to Mac. So yeah, I get that moving to another platform/environment/tool is not necessarily an option.

The obvious option (to me) is to simply keep Delphi 12 around. That seems kinda silly if the only reason is to be able to configure formatter options and then run the formatter from Delphi 13. But I hope that the lack of a formatter will soon be resolved.

Until then, a lot of people are complaining. Loudly!

Roland Bengtsson (not verified) Wed, 09/17/2025 - 19:52

I read that some people are upset that Embarcadero removed formatter. I am not.

I understand that IDE is written in Delphi except modeling that they now remove. And formatting rely on modeling. So now IDE is written in 100 % Delphi? To write formatter from scratch is a challenging task that take resources from other issues. And I don't use formatter...

pj (not verified) Wed, 09/17/2025 - 23:47

What about using the code formatter from CnWizards?

david Thu, 09/18/2025 - 06:00

In reply to by pj (not verified)

Yes, I think CnWizards is another option, one I didn't think of because I don't use that one. There's a lot of overlap (and possibly some conflicts) with GExperts which I do use.

Thanks for mentioning this.

John Cooper (not verified) Thu, 09/18/2025 - 04:48

Parnassus bookmarks and navigator have also disappeared. I expect we will get them back sooner or later, perhaps before the next version.

My produdctivity will go through the floor

david Thu, 09/18/2025 - 06:01

In reply to by John Cooper (not verified)

I hope they will be available soon; not sure why they can't be ready the same day as the rest of the product.

DelphiCoder (not verified) Fri, 09/19/2025 - 04:39

In reply to by John Cooper (not verified)

This also was the case when D12 was released. Just stay with D12 until all GetIt packages and plugins relevant for you are available for D13! :)

   

 

 

Nathan (not verified) Thu, 09/18/2025 - 07:49

Like they couldn’t have just had some AI rewrite the code formatter in pascal for them? Really don’t deserve my money anymore. First they take away my ability to continue maintenance on the FireDAC addon ther I PURCHASED, then they remove the ability to undock editor windows, now they remove probably the most useful feature of the IDE (all of the rest of the “features” I never use). That l, and the fact that the IDE and debugger get slower and slower every major release just isn’t worth giving them anymore money.

Steve Sinclair (not verified) Fri, 09/19/2025 - 08:27

I think it's good that they are facing up to the fact that some of their technology needs completely rewriting.  

Delphi has a fantastic legacy, what other tool available today could you open and compile code written in the 1990's.  And create modern powerful cross platform apps for today’s world.  However the desire to stay compatible with the past is a two edged sword.

They clearly haven’t got the resources that the big players have but I think on the whole they do a good job.  What’s more because they are smaller they can interact with us better.  Software development is hard, commercial pressures make it harder.  It’s easy to complain, yes it costs a fortunate to buy a Delphi license but most of us have made a pretty good living out of it.

If there is something out there that works better for you then use that.  I’m happy that Delphi is still a thing, for a while it looked like it was going to disappear all together. 

Add new comment

The content of this field is kept private and will not be shown publicly.