Thursday, January 24, 2008

Make a better Delphi

Delphi is a good language and Delphi IDE is a good development environment and together they make a good pair, but admit it - Delphi language is missing some modern language constructs (parameterized types, for example) and Delphi IDE can be rough at the edges. We can't do much about the former, but Delphi IDE can be greatly enhanced by installing third party add-ons (and great thanks to Borland/CodeGear for enabling us to do so).

Recently I've noticed that I can't really function well on a bare-bones IDE. I'm heavily dependent on three IDE extensions - GExperts, DDevExtensions, and ModelMaker Code Explorer. I decided to dedicate some blog space to them and describe what they do and why I like them.

It would take too much space to describe every aspect of those three add-ons, so I decided to focus on a navigation in a broad sense - moving inside unit, between units, between code and design view etc. Even more, I won't cover every navigational helper in those three, I'll just focus on the features I'm using regularly.

Delphi IDE

Delphi IDE has some neat navigation tools built in. First, there are markers. You can drop ten markers by pressing <Ctrl><Shift>number, where number is a numeric key from 0 to 9 (you don't have to use numeric keyboard keys, standard keyboard numbers will work just fine). By pressing <Ctrl>number you'll be transferred to the line containing the marker. To delete a marker you just press <Ctrl><Shift>number while the caret is positioned in the line containing the marker.

Another neat feature of the Delphi IDE is the ability to jump from method implementation to its declaration and back. The shortcut for this operation is <Ctrl><Shift><UpArrow> or <Ctrl><Shift><DownArrow> (both work the same).

Delphi: find referencesWhen you want to find where some identifier is used (in current unit and in the rest of the project), you can use find references (<Ctrl><Shift><Enter>) command. I'm mentioning it here because you can also use it to jump to the place where the identifier is used.

I'm also using the unit list (<Ctrl><F12>) and form list (<Shift><F12>) regularly. First shows the list of units in the project and second the list of forms. Just double-click the unit/form or select it and press <Enter> and it will open in the IDE.


GExperts is a set of freeware experts that enhance Delphi IDE in various ways. Only small subset is connected to the navigation.

GExperts: open fileOne of the most useful helpers is open file expert. Press the key (I have it configured to <Ctrl><Shift><Alt>O) and up pops a list of all files that are accessible from the current project. You can select the unit and press <Enter> to open it (alternatively you can double-click that unit) but before that you can - and that's even more important - start typing in the filter box and the expert will remove all non-matching units.

GExperts: procedure list

Another useful tool is procedure list expert. As the name suggests, it presents a list of methods in the current unit, which you can, of course, filter by typing. Double-click or <Enter> will beam you to the selected method.

GExperts: form designer menuGExperts also offers bunch of helpful editor experts. Locate matching delimiter (<Ctrl><Alt><LeftArrow>/<RightArrow>) jumps to a matching delimiter - from left to right bracket, from begin to end, from implementation to interface and so on. Locate previous/next identifier (<Ctrl><Alt><UpArrow>/<DownArrow>) locates previous/next occurrence of the identifier under the caret.

The last navigational help in the GExperts is hidden in the form designer pop-up menu. It is extended with the find component reference command. Right-click on a component or control and select this option and GExperts will bring up the editor, focused on the part where this component/control is declared. Or used for the first time in the code. Sometimes former and sometimes latter and I can never guess which one it will be.


DDevExtensions: unit listDDevExtensions is developed by Andreas Hausladen, author of well-known DelphiSpeedUp. I'm mostly using it because it reconfigures the <Tab> key to indent a block of code and <Shift><Tab> to unindent it, but that's not a navigational extension so you can pretend you didn't hear that from me. It also implements smart home functionality. First time you press the <Home> key, caret will jump to the first column in the row. If you press the <Home> button again, caret will jump to the first non-blank character in that line. Useful.

DDevExtensions also redefines unit list and form list keyboard shortcuts so that display a list that can be filtered - similar to the GExeperts' open file expert.

ModelMaker Code Explorer

MMX: ExplorerModelMaker Code Explorer (or MMX as it is usually called between loving users) is one of the largest Delphi IDE add-ons on the market. Its most important functionality is refactoring - creating classes, fields, properties, and methods becomes lightingly fast with MMX - but it also offers some navigational functionality. MMX is not free like GExperts and DDevExtensions but I can assure you that it's worth every cent.

An important part of MMX interface is the Explorer window. It lists every class and method in the current unit, has movements synchronized with the editor and is filterable.

MMX: indexerSimilar to Delphi's find reference is find in module command (<Ctrl><Shift><Alt>F). It locates all occurrences of  the identifier in the current module and uses tabbed interface to store old searches. Great advantage of MMX over Delphi is that it works in older IDEs and that it works on a non-compilable code.

MMX also offers extended up/down navigation. Delphi's shortcuts <Ctrl><Shift><UpArrow>/<DownArrow> are redefined to jump (in addition to the default behaviour) between propery declaration, its getter and setter, between constructors and destructors and between overloaded methods. Highly useful.

MMX: global historyThe last enhancement on my today's list is global history. MMX will automatically remember any method where you spent more than a few seconds. When you press the keyboard shortcut (I have it set to <Ctrl>` - the latter being the key left to the '0' key), MMX displays pop-up menu with most recently edited methods. Click one and you're instantly transferred there.

Other enhancements

That's all by me, I've exhausted my knowledge. Here's where you, dear reader, can help. If you know a trick that I didn't mention or a helpful expert that I don't have installed, do tell me about it in the comments. You'll help me and other Delphi programmers.


  1. Anonymous23:51

    Not to be forgetten: CnWizards. It is now my choiced IDE add-in. (together with GExpert and DelphiSpeedUp).

  2. Gaetan SIry03:23

    How about CNPACK ?

  3. JabulaZA08:24

    Agreed on all you said in the post.
    One more vote for cnWizards, although there is quite a bit of overlapping functionality between GExperts and cnWizards.
    (I saw the Home key functionality but where not aware it is ddevextensions that added that functionality)

  4. Heinz Z.08:34

    I think the reconfiguration of the Tab-key to indent a block of code and Shift-Tab to unindent is not a feature of DDevExtensions.

    It don't work in my IDE and it is also missing in the feature list of DDevExtensions (and thats sorry because I like to have it). Is there a hidden Option?

    Perhaps an other tool is responsible for this behavior.

  5. Beta Xiong09:37

    CnWizards do have all unit list, form list, open file and tab order wiz, and much more...

  6. @JabulaZA: Yes, the cnWizards build heavily on the GExperts codebase.

    @Heinz Z.: Sorry, I forgot to mention that you need a snapshot build of DDevExtensions. Snapshot builds are not linked from Andy's main web site. You have to follow a link he published in an old blog entry (where he also announced the Tab support):

  7. Anonymous13:41

    Some other modern language features that show Delphi's age:

    The inability to declare variables locally (must use a VAR section)

    The need for separate declaration and implementation areas for object methods, properties etc.

    The inability to declare local scope blocks in a procedure (WITH would do it, but it's implementation in Delphi is ambiguous and the IDE doesn't help you.)

    These made sense in the days when processors were slow and RAM was expensive, but C# has opened my eyes to how development speeds up when you leverage the huge power of modern PCs. Pity there's no W32 C# compiler.

  8. M Liesén14:01

    Thanks a 1000-times for pointing med to DDevExtensions. Finally I can leave some of the dark-ages-shortcuts behind me (Ctrl+K+I / Ctrl+K+U).

  9. Castalia!

    Things I love about it:
    1. Structural Highlighting!!! The colored lines to link begin/end pairs (as well as try/end, repeat/until, etc.) together help visualize code.
    2. Flow Control Highlighting. I have it put the markers in the gutter so I can glance through a procedure and find various exit points in the code. While I try not to have Exits at random points in code, sometimes exceptions need to be raised in strange places.
    3. Parenthesis Matching. I prefer its style to BDS 2006's.

    Those are the main things I love about it. The Navigational Toolbar is pretty nice too. It also has its own implementation of Code Templates and Refactoring for those still hanging onto (or stuck on!) Delphi 7 and earlier.

  10. The things I hate about Castalia - 1. unstable. 2. unstable. 3. unstable.

    I never found any other add-on that crashed Delphi more than Castalia.

    Things may be better with newer versions but I'm so scared of it I don't even want to test it.

  11. Anonymous23:16

    I've been using gexperts and castallia 4 in d2006 and now Castallia 5 since d2007 came out and except for the menu crash lockup due to a memory locking issue, I've never seen a crash that I can contribute to Castallia in the almost year since C5 has been out. Wish I could say the same about d2007 itself but it hasn't lost any of my code and the main error I see is when the ide is closed.
    I really like the tab/shift-tab in(un)dent feature and the one-click block comments and the unit navigation bars and have come to depend so much on the block matching highlighting that I feel lost in d7 now. I like the paragraph matching in C5 much better than Delphi's also.

  12. I have to say about my program Comfort On-Screen Keyboard.
    It is convenient to use as a shortcut reference for applications.
    See shortcuts for BDS 2006 here:

  13. Something else I forgot: Ctrl+click on identifier will jump to it's declaration. Higly useful. Works in all modern Delphi IDEs (can't remember when it was implemented).

  14. Ctrl+click to go to the declaration was introduced in 5 I believe. It is a great feature.

    I've used the latest version of Castalia and it is stable. I turn off a lot of the features (templates and the search) because I am familiar with how Delphi does those natively, and I don't think it adds much over the native support. I imagine if you were using an earlier version of Delphi these features could be a lot more valuable.

  15. Anonymous00:40

    With Delphi 2007, I use:

    Delphi Speedup
    Castalia 2008.2 (30-day Trial)

    Delphi Speedup is a must-have.

    GExperts is free and includes really nice experts (I use the messagebox wizard often and the code snippets library is nice too).

    Castalia 2008.2 isn't free but it is really nice (I installed it recently). An older version I tried a couple years ago was buggy as hell, but the current one has been very stable for me--I'm buying it unless I run into serious bugs over the next week or two.

    With Castalia, I can declare variables in the middle of my functions and it will automatically put them in the correct spot for me. And it adds two dropdowns above the editor so I can navigate quickly to a function (in fewer clicks than GExperts).

    I haven't tried ModelMaker Code Explorer (MMX) yet but I'm going to try it later this month.