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
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 adds some very useful features to Delphi, such as Grep search
Alt + Shift + S, Procedure List
Ctrl + G, Rename Components and other very handy shortcuts (see the shortcut section for more).
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.
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 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.
The following shortcuts will be speed up your coding a lot:
- 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 upor
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
Alt + F11to 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 🙂
Ctrl + Sand save all:
Ctrl + Shift + S
Ctrl + F9and 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(type your statement, place cursor on variable and press the shortcut)
- 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)
- Refactor code to new procedure:
Ctrl + Shift + M
- Synchronize procedure or function parameters:
Ctrl + Alt + Shift + P
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
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.
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: https://github.com/Fr0sT-Brutal/awesome-pascal
This is a quite extensive list of many Delphi / Pascal packages, libraries and tools.
- Spring4D framework: https://bitbucket.org/sglienke/spring4d/src/master/
Spring4D is superb, we love the IEnumerable based generic collections.
- Inno Setup: www.jrsoftware.org/isinfo.php
Use Pascal in your setup files. See also https://medium.com/@marcogeuze/inno-setup-for-delphi-packages-6b6d52dba1b9
- Delphi GitIgnore: https://github.com/github/gitignore/blob/master/Delphi.gitignore
Use this as a master gitignore, so you never have to worry about the _history folders anymore 🙂
- madExcept: http://www.madshi.net/
Exception handling at it’s best.