Knowledge Base

Delphi tips and tricks

At GDK Software we have been working with Delphi for years. We have collected quite a few tricks and tips, which I would like to share with you. I have organized Delphi’s tips and tricks into the following topics:

  • Delphi plugins
  • Delphi IDE Shortcuts
  • Live Templates (or Code templates)
  • Various useful links

Delphi plugins

As a Delphi developer, you are working with the Delphi IDE on a daily basis. And although the Delphi editor works fine by itself, with the following plugins you can make your work even easier:


GExperts
GExperts adds some very useful features to Delphi, such as Grep Search Alt + Shift + S, Procedure List Ctrl + G, Rename Componenten and other very handy shortcuts (see the shortcut section for more).

DDevExtensions
We love DDevExtensions for the Find Unit/Use Unit replacement dialog (Alt + F11). The default Delphi Use-Unit dialog only shows the files from the project group. DDevExtensions replaces the dialog with one that not only shows the project group files but also all files that the compiler can see. Never again navigate to the uses section and insert a unit by hand, just hit Alt-F11.
DDevExtensions also prevents the IDE from storing the ExplicitWidth and ExplicitHeight properties to the DFM.

Delphi IDE Fix pack
The IDE Fix pack optimizations let the IDE start faster, open projects faster, optimizes the compiler’s file search algorithm, makes CodeInsight, the actual compilation and the debugger faster.

Parnassus Bookmarks
Parnassus Bookmarks replaces the IDE’s inbuilt functionality with new, improved navigation. Bookmarks are saved so that after a restart the bookmarks are still available. Installation can be done via the GetIt package manager.

Delphi IDE Shortcuts

IDE Shortcuts are the easiest way to speed up development. Most of us undoubtedly know the most important shortcuts in Delphi, but let’s share which ones we use regularly.

(Here you can find all the Delphi shortcuts)

  • Bookmarks: Save the points in code where you want to come back. Navigate easily through code. Set a bookmark with Ctrl + Shift + <Number> and use it with Ctrl + <Number>.
  • Jump between the methods interface and implementation with Ctrl + Shift + Arrow up or Ctrl + Shift + Arrow down.
  • Install and use the Grep Search from GExperts. Searching faster and representing the results in a better view than the Delphi IDE via Alt + Shift + S.
  • (GExperts) Search and go to a method with Ctrl + G
  • Use Alt + F11 to add a unit to your code (use with DDevExtensions).
  • Use a clipboard manager to copy several things without continuously swapping between copy/paste, copy/paste, etc. We prefer CLCL for clipboard history, you can easily use it by pressing Alt + C. Despite this not being a specific Delphi suggestion, I still want to share this. If you only want to use one of these tips, let it be this one.

Other popular shortcuts are::

    • The obvious ones 🙂
      Save: Ctrl + S and save all: Ctrl + Shift + S
      Run: F9, compile: Ctrl + F9 and build: Shift + F9
      Stop run / debug: Ctrl + F2
    • Add a file to the project: Shift + F11
    • Complete a class: Ctrl + Shift + C (i.e. create the methods in the implementation section)
    • Declare a variable: Ctrl + Shift + V
    • Declare a class-variable: Ctrl + Shift + D (same as V, but instead of the local variable you’ll end up with a class variable)
    • Rename a variable: Ctrl + Shift + E
    • Go to unit: Ctrl + Enter(when your cursor is on a unit name). Faster than Ctrl + click , but only works if Delphi can locate the unit
    • Align your codelines with Ctrl + Alt + Z (GExperts)

Ctrl + Shift + M

  • Synchronize procedure or function parameters: Ctrl + Alt + Shift + P

 

Live Templates

Live Templates (or Code templates, as they were formerly called) are a very useful feature of Delphi. Since Delphi 3 these templates are present in Delphi, but we still see that this handy feature is undervalued. Most developers are familiar with the code completing of if or while, where the structure of the statement is created automatically.

But with Live Templates you can automate much more. If you want to see a list of the available Live Templates, you can use the shortcut Ctrl + J.

The more you can automate, the better it is. That’s why it is recommended to create your own live templates for frequently used code within your program. This can easily be done via File -> New -> Other -> Code Template. For more information about the structure of the templates, you can find more information on the wiki of Embarcadero.

Useful links

Delphi has been around for more than 25 years now. It is therefore impossible to put all possible tips and websites on this page. Below I will list some links to frameworks, tools or code libraries that we at GDK Software regularly use.

  • Overview of Delphi / Pascal libraries: Awesome Pascal
    This is a quite extensive list of many Delphi / Pascal packages, libraries and tools.
  • Spring4D framework: Framework
    Spring4D is superb, we specificly love the IEnumerable based generic collections.
  • Inno Setup: InnoSetup
    Use Pascal in your setup files. See also Medium
  • Delphi GitIgnore: GitIgnore
    Use this as a master gitignore, so you never have to worry about the _history folders anymore 🙂
  • madExcept: Madshi
    Exception handling at it’s best.

Written by Marco Geuze
Director

Contact

Let us help you to realise your ambitions

GDK Software UK

(+44) 20 3355 4470

GDK Software USA

+1 (575) 733-5744