Friday, May 29, 2009

Keystroke Combinations in Delphi’s Code Editor

There are many advantages to being a Delphi developer. Not only has the language kept pace with improvements added to other languages, such as C#, but it has maintained a remarkable consistency over its many years, first as Turbo Pascal, and later as Delphi. For example, routines originally written for Turbo Pascal in the 1980s often compile in the latest version of Delphi with little or no changes. There are not many languages you can say that about.

Delphi developers have also benefited from Delphi’s strong IDE (integrated development environment). From Delphi 1 through RAD Studio 2009, Delphi’s IDE has provided developers with state-of-the-art features that support and improve the overall development experience.

Unfortunately, not all of the capabilities of Delphi’s IDE are well known. Consider this. Did you know that Delphi can record (Ctrl+Shift+R) and playback (Ctrl+Shift+P) a series of keystrokes? It’s my impression that at least half of Delphi developers do not know this. But it is a feature that has been available in Delphi since Delphi version 1.

Part of the problem is that the various keystrokes supported by Delphi’s IDE have been notoriously hard to find in Delphi’s help. Some of them have never been documented. For example, one of my favorite keystroke combinations is Ctrl+Spacebar, which invokes the Argument Value List drop down. Whenever you are entering the value of an expression, for example, the left side of an assignment statement or a parameter of a function, pressing Ctrl+Spacebar displays a list of the possible symbols that might satisfy the expression. This feature, which was added in Delphi 3, appeared in the Delphi 4 help files only. It wasn’t in Delphi 3’s help, and has been missing in action since Delphi 5.

Another interesting item to note is that, although Delphi’s IDE has undergone major revisions in the past few years with the introduction of the Galileo IDE, the keystrokes available in the IDE, and the editor specifically, have not changed much at all. In particular, nearly every keystroke combination that was available in Delphi 1 still works in Delphi 2009.

But there is still the problem of documentation. When I inspected the most recent help that ships with RAD Studio 2007, I found that just over half of the editor’s keystroke combinations appeared in the help. The others were nowhere to be found.

And this brings us to the essence of this article. I have attempted to collect here, in Table 1, every editor keystroke combination that I am aware of. These keystroke combinations are for the default key mapping, which is used by most Delphi developers. If you are using one of the other key mappings, some of these combinations will not work, but many will.

I also want to admit that most of this table’s contents was derived from Delphi’s help files. In other words, while I compiled this table, I did not write most of the entries. Some entries appear exactly as they did in the help files, but I wrote some as well.

Furthermore, I edited many of the help file entries, either to make corrections or to simplify the description. I also removed entries that were in the help files that either didn’t work correctly, or appeared to not work at all. Finally, I didn’t include many keystrokes that are not code editor specific. For instance, I did not include debugging related keystrokes.

Permit me to list these main points again:

  1. These keystroke combinations are only for the code editor. I did not include debugger keystroke combinations or general IDE keystroke combinations

  2. These keystroke combinations are for the default keybinding. I made no attempt to include keystroke combinations for other keybindings

  3. Many of these descriptions are derived from some version of Delphi’s documentation

  4. I listed these combinations in alphabetical order. Yes, there are many other alternative orders that would have been useful as well, but I opted for an alphabetical order for simplicity

  5. I know that there must be some valid keystroke combinations that are missing (I specifically omitted those that did not appear to work). If you know of valid editor keystroke combinations that apply to the default keybinding that are missing, feel free to email those to me at I will try to update this table periodically with your contributions

So here, for your consideration and enjoyment, is a zip file that contains a PDF of a nearly complete list of the keystrokes supported by Delphi’s editor. This list is presented in alphabetical order, by key. When two key or key combinations perform the same task, they both appear in the left column.

Cary Jensen's Delphi Editor Keystroke Table

Copyright (c) 2009 Cary Jensen. All Rights Reserved.


  1. This comment has been removed by a blog administrator.

  2. "There are many advantages to being a Delphi developer. Not only has the language kept pace with improvements added to other languages, such as C#"

    Sorry, but in my opinion, this is incorrect. As understand it, it was only the current version of Delphi that brought in modern language features like generics and closures. There was no reason why generics couldn't have been included in Delphi 7, for instance - the technology was there.

    If Delphi had kept pace with C# in a timely fashion perhaps people wouldn't have left it in droves for .NET.

    Barry Carr

  3. Generics were added to C# in .NET 2.0, which was published significantly later than Delphi 7.
    As far as developers leaving Delphi due to it's arguable lack of modern language features, please consider that there are still more developers developing in Visual Basic 6 than in .NET.

  4. @Barry, Delphi got closures before Java.

  5. Cary,

    Great list, probably comprehensive. Easy for you to check that you've got them all, but difficult to make use of in alphabetical order.

    You might want to note this:

  6. Nice. There are a few goodies in there.

    But it would have been even nicer if the keybindings were somehow grouped by functionality instead.

    Personally, I think it is overkill to include keystroke combinations such as copy/paste as well as backspace, space, tab, up/down arrow (Those aren't even combinations...). I would expect the effects of pressing spacebar, backspace, a-z etc. to be obvious...

    Maybe if it was boiled down to the essentials it could fit onto a single printout - which would be nice for pinning onto the wall next to my screen for easy reference.

    On another note, I do not entirely agree with the 'keeping in pace' part. In my opinion, there have been no significant changes to the language between D7 and D2009 (apart from the abomination that was Delphi.NET).
    And even with the additions that HAVE come, some of them still have a significant 'beta' feel. Generics are still rather buggy both at compile- and run-time.
    But at least D2009 is a pretty stable IDE compared to the 2005-2007 releases, all of which were prone to sudden crashes and weird exceptions.

  7. >Not only has the language kept pace with improvements added to other languages, such as C#,

    Come on Carry. It's 2014 now... where is the operator overloading of classes, generics for first class functions, string in case statements, automatic memory management (I know Marco keeps saying this is coming but no firm idea when yet), tuples, generators, comprehensions, package management (e.g. NuGet, CRAN, CPAN, PyPi, etc.), slice notation, design by contract, type inference, lambda, filter/map/reduce, heck a step for the for loop, stack traces, memoization, *real* sets as opposed to the bitmapped 255-element construct we've had since Turbo Pascal, operator overloading for classes, partial functions, a decimal type, a real complex number type, arbitrary precision integer support, refactoring of the VCL to add iteration support everywhere such as files, database results, strings, etc. They've even closed a QC request to be able to iterate through an enum as "won't do"!

    This is just the stuff off the top of my head. I won't even go into stuff like C#'s LINQ. Oxygene has dozens of features Delphi doesn't have and DWScript and Nimrod also have quite a few. Heck, Python is far more advanced in many areas: the sets are unlimited in size and can contain any hashable value. You can feed a file through a set and get a set of unique words while we're stuck with numbers/enums no higher than a byte's value. :-( If x in [0,1,3] is valid code but If x in [0,1,400] is not. If x in ['this', 'that', 'whatever'] is an impossible dream. :-( I've used sets more than a few months in Python than in 24 years of Turbo Pascal - Borland Pascal - Delphi.

    >For example, routines originally written for Turbo Pascal in the 1980s often compile in the latest
    >version of Delphi with little or no changes. There are not many languages you can say that about.

    That's a terrible thing to say about a language. That means the language hasn't grown. Heck, worse, it means it *hasn't fixed its mistakes*. Every language has mistakes that require breaking compatibility to fix. If you don't, it can end up hobbled and/or end up with a ballooning standard library and multiple versions of many functions (Java suffers from this). The set example is a good one. That sets still work like Turbo Pascal is a shame. That one still uses a While and EOF loop to read through database results is a shame. That "in" doesn't check for membership in everything (strings, dictionary keys, etc.) is a shame. That according to Barry Kelly RTTI will never work for enums with a custom value because it would require breaking backward compatibility (although he didn't specify with what) is a shame. As Guido Van Rossum once observed, all the code ever written pales in comparison to all the code yet to be written. Backward compatibility at the expense of hobbling developers for all time is a terrible tradeoff to make IMHO. Look at BASIC - it realized it lost the GOTO Wars and dumped the line numbers and adopted structured programming and its descendents such as Visual Basic went on to enjoy quite a bit of popularity even though there was essentially zero backward compatibility. Heck, Turbo Pascal made quite a lot of changes from the original Pascal (such as its very broken string implementation) and Delphi has certainly departed radically from ISO Pascal since.

    All that said, good work on the compilation of key bindings. :-)