Delphi 6 Code Completion missing feature

By: Brian Long

Abstract: This article explains how to enable an excellent new Code Completion feature in Delphi 6. By Brian Long.

Delphi 6 introduced a number of improvements to Code Completion, which was originally delivered as part of Delphi 3s Code Insight feature set. The most obvious improvement is that Code Completion now appears as a color-highlighted, resizable window. It is also typically more responsive than it was in Delphi 5, and it incrementally reduces the options offered as you continue to type.

There are more new Code Completion features than these. You can find out more about them and see them in action at, which is part of Steve Trefethens Web site. Steve is a member of Borlands Delphi R&D team.

The reason for this article is that one of these new Code Completion features -- which is mentioned on Steve's Web page and in Delphis online help -- does not work in a normal installation of Delphi 6 (with or without Update Pack 1 installed). The R&D people are rightly very proud of this feature, but since the installation program does not set it up correctly, we Delphi programmers are missing it. This article describes the missing feature and explains how to enable it.

You can download the utility project described in this article from Code Central.


This is the definition of the missing feature, as specified in the Delphi 6 help for Code Completion:

On a blank statement line, press Ctrl+Space to display symbols from additional RTL units even if they are not used by the current unit.

The Whats New help file says much the same thing:

When you manually (Ctrl+Space) invoke code completion on a blank statement line in the body of a routine, the pop-up list box now shows symbols from additional RTL units even if they are not used by the current unit.

This enhancement was made to allow you to keep typing code, using Code Completion when you couldnt remember the exact identifier name (or didnt want to manually type it all) without being obliged to keep jumping to the uses clause first to make sure it has the correct unit listed.

In fact, if you select something from the Code Completion list that comes from a unit not already in your uses clause, that unit name will automatically be added to it for you.

Note that this applies only when Code Completion is explicitly invoked with Ctrl+Space, and has no effect on the normal auto-invoked Code Completion (which pops up automatically when you type an object reference or record variable and then a full stop).


The full list of units that Code Completion is prepared to look in should be stored in this registry entry:

HKEY_CURRENT_USER/Software/Borland/Delphi6.0/Code Insight/ExtraUnits

Unfortunately, this entry does not get set up by the Delphi installer, so the feature is not enabled by default. Instead, probably due to an oversight, the installer sets up an entry:


This entry contains what looks like a healthy list of semicolon-separated unit names for the described purpose, but there is a variety of problems with it:

  • It is installed in the wrong registry key (CodeCompletion instead of Code Insight).
  • It contains a typo in one of the unit names: the HelpIntfs unit has a semicolon in the middle of it, making it references to two non-existent units: Help and Intfs.
  • It contains DelphiMM, which is not a unit but a DLL project file.
  • It contains StdMain, which is not a unit supplied with Delphi.
  • It contains some pointless units, which are always implicitly used by all Delphi source files anyway, namely System and SysInit.

Each of these problems (other than the last) causes a problem. The fact that the value is in the wrong key means that no extra units are searched at all. The erroneous entries in the list mean that even if it were in the right key, Code Completion would still fail to appear when invoked with Ctrl+Space, because an errant or non-existing unit in the list completely breaks manually invoked Code Completion. Both problems have been reported, but the problem is not rectified by Delphi 6 Update Pack 1.


We can bring the feature into play ourselves by creating the missing registry entry and ensuring that only valid unit names are in the list. The project CodeCompletionSettings.dpr accompanies this article and implements a utility program that lets you set up this missing functionality.

The program allows you to set up the list of extra units as required. It also supports tailoring of the colors used in the Code Completion window, as described in the Code Completion help. These colors are stored in the same registry key as the correct location for the extra units to search. One additional feature it lets you control is whether Code Completion will add parentheses when entering the name of a routine that expects parameters to be passed. Delphi does this for you by default, but you can disable the feature if you wish.

You can see the program running below.

Code Completion Settings Utility

The code that sets up the extra units reads the appropriate registry entry and shows the current value (which will be blank by default), offering to set up a corrected version of the erroneously placed default unit list if required. You can then add units to the list or remove unwanted units as needed.

Note that each time you press Ctrl+Space, Delphi re-reads the registry entry, so you can modify the value with this new program while Delphi is running and it will instantly take note of units you add. Just remember that if Code Completion suddenly refuses to appear, it is most likely because you have an invalid or non-existent unit in the list.

The screenshot below shows Code Completion being used in a fresh project with just a button on it. Since ComObj is in the list of extra units stored in the registry, Code Completion will show CreateOleObject (which is declared in the ComObj unit) and, if chosen, will add ComObj to the uses clause automatically.

Missing Code Completion Feature


Brian Long used to work at Borland UK, performing a number of duties including technical support on all the programming tools. Since leaving in 1995, Brian has been providing training and consultancy services to the Delphi and C++Builder communities, and the newly forming Kylix community.

If you need training in these products, or need solutions to problems you have with them, please get in touch, or visit Brian's Web site.

Besides authoring a Borland Pascal problem-solving book published in 1994, Brian is now a regular columnist in The Delphi Magazine and has had numerous articles published in Computing, Delphi Developer's Journal, Linux Format, Developers Review and EXE Magazine.

In his spare time (and waiting for his C++ programs to compile) Brian has learned the art of juggling and making inflatable origami paper frogs.

Server Response from: ETNASC01