Shortcut key in Delphi 12.2 Pro update 2

I want to access the automatic formatter as I’m finding the whole tabs vs spaces thing quite laborious really

In C++ Builder CTRL+D was the go, but in this version it does nothing. Any clues what I’m doing wrong?

In C++Builder, I think (without checking) I think Visual Assist might be the method for formatting now … ?

In Delphi, using uptodate stuff like inline vars breaks the ^D formatting. I’m not sure there is an in-the-box alternative.

BUT … there was a fb post about an apparently working version :

Thanks Paul.
I am using Delphi on this project and not C++ Builder, sorry for any confusion.

Its not the version (Embarcadero® RAD Studio 12 Version 29.0.53571.9782) either. My co-worker is using the same Delphi version on the same project and ^D formatting works for him perfectly. Both were installed on recent installs of win11. Outside of Delphi the control keys work as expected.

Not sure why it doesn’t work for me or how to find out what is going on. Suppose a Delphi reinstall is the easiest solution
Cheers
Aneal

1 Like

Could it be that you have a third party expert installed into the IDE that is grabbing the keyboard shortcut? Perhaps try disabling all experts and see if that fixes the problem?

2 Likes

Could someone have renamed the dll that gets called when you press ^D?

There’s that many that don’t appreciate what ^D does that the dll to rename is documented in a google search or two

I haven’t maintained it but I did “release” GitHub - NickRing/Delphi-Shortcut-Finder: Shows/find keyboard short-cuts have be assigned, that may be conflicting. that is meant to check to see what key press goes where-ish (within Delphi).

Maybe you can upgrade it for Delphi 12.2 and that might track it down.

I do know that the order of some add-ons will change how key presses will be handled :slightly_frowning_face:

Did you by any chance disable “Modeling” during installation? It might have an effect on the formatting too iirc

Good catch. If modeling is not installed, then the code formatting doesn’t get installed either because (due to historical reasons) it’s part of that package.

You can check it’s definitely installed by right-clicking on an editor window containing some Delphi source code - the context window which pops up should have the format source option in it.

image

If that is showing but the shortcut is not working, then it’s definitely an add-in or the keyboard shortcut has somehow not been bound to that function.

If the function doesn’t appear in the right-click menu then it’s not installed and you need to save your project (and close it) then from the main IDE window select tools–>manage features.

The installer window will open, scroll down until you see modeling - and make sure it’s checked. Then let the installer do its stuff.

Thanks everyone for the quick resolution :slightly_smiling_face:

Yes Eivind I unticked modelling during the install. I followed Ian’s easy steps and now have ^D’s powerful functionality in Delphi enabled

The installer most helpfully doesn’t display everything Modeling is used for in the mouseover hint in the installer. An area for improvement…

1 Like

Definitely.

Also, the code formatter is currently very suboptimal and gets confused by inline vars and multiline comments. :flushed:

We’re looking into how best to deal with it but it’s more complicated than it looks for historical reasons.

@ianbarker I feel VSCode sets the gold standard for things like Code Formatting. It would make a lot of sense for RAD Studio to provide an interface to support VSCode plugins rather than building something that cannot be changed. This then allows the community or individual teams to build out code formatting that conforms to the ways that team has decided code should look. If this was possible, you would also benefit from all the existing formatters for JSON and other languages.

It’s an interesting point.

Code formatting is not really about how VSCode or even RAD Studio thinks it should look - the standard should be it formats the code according to some agreed standard, either a public, published one, or more frequently, the standards of a company’s dev team. So, customizability (such as tabs v spaces, types of indentation, etc etc) is important as is being able to save the customizations and, in an ideal world, export them so a team or new hire to the team can import them and all format their code the same way.

The most popular VS Code Pascal/Delphi code formatter is from Alessandro Fragnani (he has some excellent VS Code projects) and that actually leverages external projects including Free Pascal, two from the Jedi project and our own Embarcadero one.

I’m open to ideas. My two pet “not quite right” features are the code formatting and the sync prototypes refactoring, and I’m genuinely interested in getting those improved if at all possible.