views:

6855

answers:

47

The "Hidden Features" series here on StackOverflow has generated some really interesting feedback. So what about my favorite IDE, Delphi? What are some hidden features there?

I'll start with one of my own:

You can invoke inline find by typing Ctrl+E, then typing your search term.

A: 

Random access violation errors generator.

Not that helpful (I didn't vote you down though...), but... FUNNY!!
Graza
Yes, this is *so* typical! I hate random AV errors! They are not funny to debug.
Andreas Rejbrand
+8  A: 

CTRL + Shift + C generates method header from body description and vice-versa.

CTRL + Shift + Space gives a hint with method signature when editing a method call

Gustavo
Ctrl+Shift+C will also generate the required FSomeProperty, GetSomeProperty() or SetSomeProperty() declarations if you declare "property SomeProperty: SomeType read FSomeProperty write SetSomeProperty;" for example
Graza
I kinda wish the default field/getter-setter method scope was "strict private" though. Or even better, configurable so it could be "strict protected" if you use that more commonly...
Graza
It is configurable - if you use ModelMaker Code Explorer ...
gabr
Unfortunately class completion does not work right if strict private or protected sections already exist on a class. I think it should reuse those. Instead it adds a new private section. And (the kicker) it adds an empty published section.
deepc
+3  A: 

Ctrl-Shift + Up/Down jumps between declaration and implementation of a routine

Oliver Giesen
+1  A: 

Ctrl-Alt + Up/Down performs a word search on the symbol that the cursor is currently located on

(EDIT: not entirely correct it seems, I think it comes from GExperts - without it, this shortcut will navigate to the next/previous function/method body)

Oliver Giesen
+1  A: 

declaring a typed constant inside a routine will actually act like a static variable with local scope, e.g.:

{$WRITEABLECONST ON}
procedure TForm1.Button1Click(Sender: TObject);
const
  i: Integer = 0;
begin
  Inc(i);
  ShowMessageFmt('You clicked me %d times!', [i]);
end;
Oliver Giesen
I believe kogus is looking for hidden treasure in IDE, not in the Delphi language.
gabr
+3  A: 

Ctrl-Shift-0 .. Ctrl-Shift-9 sets marker (or clears if caret is in marked line)

Ctrl-0 .. Ctrl-0 jumps to marker

Ctrl-Shift-Enter finds references for current symbol (where caret is) in the project

gabr
Looks like Ctrl-Shift-Enter doesn't work in D7. Is that only in newer versions?
Liron Yahdav
Since Delphi 2005, I believe.
gabr
For older versions, Ctrl-K,Ctrl<0-9> creates a bookmark, while Ctrl-Q, Ctrl-<0-n> jumps to the bookmark (if it exists).
Lars Fosdal
+3  A: 

the build order of projects in a project group can be changed with Ctrl+Up/Down
(though I would prefer drag&drop)

Oliver Giesen
+8  A: 

For me, the most important 'hidden' feature in RAD Studio is that it can be extended with experts. GExperts, DDevExtensions and ModelMaker Code Explorer are on my 'must-use' list and I cannot live without them (links to products and some description).

gabr
+14  A: 

Really hidden: Help, About, hold the Alt key and type TEAM.

gabr
up to your first comma I though this was going to be another rant about the state of the documentation... ;)
Oliver Giesen
Still there in D2007, but definitely cooler in D5.
JosephStyons
Just realized - in D2007, do this trick, then double-click on the scrolling credits to get a picture
JosephStyons
D2010 has this as well as the photo if you double-click the scrolling credits.
Red Haze
+4  A: 

Ctrl-Alt + '.' - Comment out the selected block of code

Ctrl-Alt + ',' - Reverse the above

Graza
In modern Delphis (since 2005?) Ctrl+/ does the same (in both directions).
gabr
CTRL+/ does the same thing in both directions.
Nick Hodges
Hehe, Nick, beat you :)
gabr
sweet...didnt know that one.
TrevorD
+5  A: 

Ctrl-Shift + I - Indent selected block

Ctrl-Shift + U - UN-Indent selected block

Graza
+13  A: 

In the object inspector, if you hold the [CTRL] key when you double click a property that is linked to another component it takes you to that component. A linked property is in colored maroon.

Jim McKeeth
Didn't know that one, thanks!
gabr
Nice one! I always wondered what's the quickest way to get to a linked component.
Liron Yahdav
+11  A: 
  • ESC selects the parent control of the current selected control in the designer.
  • Ctrl+Drag the mouse to select a group of controls without selecting/moving the parent. When controls are in a panel for example.
  • Shift+Arrows to resize controls.
  • Ctrl+Arrows to move controls.
Erick Sasse
Yep, those are great. Especially Ctrl+Drag is largely unknown.
gabr
+6  A: 

The debugger enhancements:

  1. Dbl-Click in the Call Stack panel on a line with a blue dot (i.e. there is debug info) jumps to the calling code (expected) but it also updates the local variables with the values in scope at this new location
  2. When the tooltip evaluation is displayed (mouse hovering a symbol), pressing Ctrl make it temporarily transparent
  3. Dragging some code expression into any of the debugger window: Watch List, Evaluate Dialog, Debug Inspector.
François
Delphi 2006 and up
Lars Truijens
+15  A: 

CTRL-Click on any identifier takes you to the declaration of that identifier.

CTRL-O-C enables block selection in the editor.

CTRL+SHIFT+I indents selected code CTRL+SHIFT+U unindents selected code

CTRL+K+N converts the selection to UPPERCASE CTRL+K+O to convert it to lowercase

You can incrementally search for an item in the Object Inspector.

CTRL-J invokes live templates -- I think Live Templates are one of the most powerful and most under utilized features in the IDE. More info on Live Templates:

http://delphi.wikia.com/wiki/Delphi_Live_Templates http://dn.codegear.com/article/37468 http://delphi.wikia.com/wiki/Live_Templates_Technical_Info

Nick Hodges
Oh wow. You don't even KNOW how much time CTRL-SHIFT-I/U will save me. Thank you so much!
Mason Wheeler
I didn't know CTRL+K+N and CTRL+K+O. Thanks...
SimaWB
+2  A: 

Up until Delphi 2007 you could drag two different components from the pallet to the form at the same time by using Shift selecting one, and then dragging a different one. I guess someone thought that was a bug and removed it though.

Jim McKeeth
+4  A: 

Ctrl+/ to comment/uncomment a block of code.

The problem with CTRL+Alt+"." and Crtl+Alt+"," is that it unmarks the block. I also like having the same key combination toggle the comments on and off.

Introduced after Delphi 7. Possibly in Delphi 2005.

Bruce McGee
What's the earliest Delphi that has the Ctrl+/ shortcut? I'm using D7 and it doesn't have it.
Liron Yahdav
+4  A: 

Ctrl-Shift-E invokes the rename refactor. It's available in Delphi 2005+. It allows you to quickly rename a function or variable and all references to it via one pop up dialog. This is the best refactor in the IDE imho.

Second best rename trick is too highlight a block of code, click on the icon that appears in the left hand gutter, then select and rename the variable you want to rename. This will rename all copies of that variable within the selection. This is most useful for renaming a local variable to split it from another copy of it.

Zartog
SyncEdit is the second feature called. You can also invoke it with Ctrl-Shift-J.
gabr
A: 

Including extensions, the must have extension from GExperts is GDebug. It's comprised of a unit and an executable.

When you include the unit you insert send messages through out your code to notify you of events, variable values, progress, etc.

The executable creates a system tray icon that simply captures all the messages and time stamps them.

The messages work inside and out of the IDE, but it's rather easy to drop some checks for 'DebugHook <> 0' into the gdebug.pas unit if you want to mute it when not debugging.

This simple tool has greatly simplified my life for situations where I don't want to setup break points, steps, hit counts, watches, etc. or for situations where the behavior is sporadic, different under the ide or not even necessarily erroneous.

Zartog
+5  A: 

Hold Alt and Drag the mouse in the editor to block-select.

Zaf Keramidas
This is similar to shift selection with cursor keys. I.e. if you also hold down Alt, then a block selection will be done instead.
Craig Young
+1  A: 

With CN Pack
CTRL-V jumps to var block and back
CTRL-/ comments in/out selected lines


Also the code block highlighter is awesome, it color codes your nested statements

Peter Turner
I upped this response because the code block highlighter is so good!
Red Haze
+2  A: 

With G-Experts
CTRL-SHIFT-S opens up a grep search (and replace) is waaaay better than searching using windows.
I prefer it even to google desktop search, which incidentally has a delphi source code plug in.

Peter Turner
I have been using a command line version of grep for windows, G-Experts is much bette. Thanks for mentioning it!
stevosaurus
I use the delphi source code plugin, but I'm sad that it does not index .DFM files.
JosephStyons
Did I miss something? Was this question about **Delphi** hidden features, or about all the extra features (possibly not even hidden) that you get if you install 101 add-ons?
Craig Young
Would you feel better if I delete this?
Peter Turner
+1  A: 

uses windows

outputdebugstring('my debug info')

I automap "ods" -> "outputdebugstring(pansichar(format("|",[]))"

and use CTRL-J to auto-do it. Very handy, you can use CN-Pack debugviewer, or sysinternals, or whatever to view the debug messages, it's way better than messageboxes and no on yells at you when you leave them in the build!

Peter Turner
+9  A: 

You probably know that Alt+F7 and Alt+F8 navigate back/forward through the results of a "Find in Files"

But did you know that when the compiler spits out a list of errors during compilation that Alt+F7 and Alt+F8 now navigate through the errors.

Nice! I didn't even know the Alt+F7/F8 for navigating through the Find in Files results. Very useful!
Liron Yahdav
+1  A: 

I'm not sure if this still works in newer versions, but up until at least Delphi 7, you can go to the Help|About dialog, hold down ALT and type TEAM.

smo
it works in bds2006
Charles Faiga
+3  A: 

Have someone mention CTRL+SHIFT+G to generate / insert a new GUID at the cursor position ?

CTRL+ALT+P to activate Pallete Window and do component filtering depend on the text you entered (Delphi 2005+)

+2  A: 

Probably not so hidden but:
Ctrl + alternating between K and I block indents code to the right.
Ctrl + alternating between K and U block indents code to the left.

Niklas Winde
Never knew that, but I find it quicker to use Ctrl+Shift+I/U
Liron Yahdav
+3  A: 

Ctrl+Click on a line in the Code completion popup (invoke via Ctrl+Space) to jump to the definition of the symbol.

Liron Yahdav
+3  A: 

Resize the Code completion popup (invoke via Ctrl+Space) by dragging its borders. The new size will be remembered.

Liron Yahdav
+6  A: 

Hidden deep in Delphi's help (Delphi 7 at least) is how to use macros (useful for repetitive tasks):

  1. Press Ctrl+Shift+R to begin recording a macro.
  2. Enter the keystrokes you want to record.
  3. Press Ctrl+Shift+R to finish and save the macro.
  4. To play back the macro, press Ctrl+Shift+P.

Tip: you can use any keyboard shortcuts available while recording the macro (e.g. Ctrl+C for copy, Ctrl+V for paste).

Liron Yahdav
Not quite 'any' keyboard shortcut. If it pops open a dialog (like Ctrl+F) it's a no-go. BTW, iirc the feature was even available as early as D3.
Craig Young
+6  A: 

If you press Ctrl+Space while in the interface section of a class, you will get a list of methods you can override and properties you can publish. Methods listed in red must be implemented (they're abstract or from an interface).

Liron Yahdav
+4  A: 

I did not discover this until recently, but now I use it a lot. If you press Ctrl-Shift-Enter while the cursor is over an identifier, you can see the places that identifier is referenced in your entire project. Very useful if you are trying to figure out where a change is happening or what you will break if you change something.

This doesn't work for me in D2007 or D2009
frogb
It's Ctrl+Shift+Enter.
Moritz Beutel
updated the text
borisCallens
+1  A: 

Navigating methods in a unit:

Ctrl+Alt+Up/Down - move to previous/next method Ctrl+Alt+Home/End - move to the first/last method in the unit

Introduced after Delphi 7. Works in Delphi Delphi 2006, but I'm not sure about Delphi 2005.

Bruce McGee
+2  A: 

Alt+End: to navigate through opened windows in the IDE (undocked view).

Ctlr+Y: to delete the current line

Alt+Up: same as Ctrl+Click or Find declaration

Alt+Arrow Left/Right: navigate through your 'Find declarations'

The_Fox
Ctrl+Y can be rather troublesome, though, because in most Microsoft applications (e.g. Word), Ctrl+Y is "redo", the inverse of Ctrl+Z, "undo". Not only will accidental use of Ctrl+Y remove the current line (and the following, if you continue to use it), it will also destroy the undo history after the current revision.
Andreas Rejbrand
+4  A: 

Team pictures

Tested in Delphi 2007 and 2009.

  • Go to Help|About
  • Hold town the Alt key ant type T E A M to get the scrolling team list.
  • Double-click on the list to see the team picture.

Bonus: - Help|About - Hold down the Alt key and type G U N G L A

Bruce McGee
+2  A: 

Select a unit or the project in the Project Manager and rename it using either F2/Inplace Edit or by changing it in the Obejct Inspector, and it does essentially the same thing as Save As...

Malcolm Groves
+3  A: 

Incremental Search in the Object Inspector here

Malcolm Groves
+3  A: 

I find the -r command line switch very useful.

TOndrej
+2  A: 

Auto-correct in the Editor

There are a handful of words I seem to regularly mistype, such as stirng for string, tehn for then, etc.

So, I define a Live Template that is keyed off the incorrectly spelled word that automatically changes it to the correct spelling. eg, this one to convert tehn to then:

<?xml version="1.0" encoding="utf-8" ?>
<codetemplate xmlns="http://schemas.borland.com/Delphi/2005/codetemplates" version="1.0.0">
    <template name="tehn" invoke="auto">
     <description>Auto-correct tehn into then</description>
     <author>Malcolm Groves</author>
     <code language="Delphi" context="methodbody" delimiter="|"><![CDATA[then |end|]]></code>
    </template>
</codetemplate>
Malcolm Groves
+2  A: 

My favorites, for fast keyboard-only navigation between many (open) units in the Delphi editor :

Ctrl + Alt + F12 opens up the top-right dropdown menu of opened units

Ctrl + F12 opens up a window with all units of the current project (or project-group if you check the mark for it)

Shift + F12 opens up a window with all forms of the current project (or project-group if you check the mark for it)

Also have a look at the DevExtensions plugin which improves upon those dialogs in various useful ways. For example : One thing I like about this extension is, that it allows substring filtering (instead of the start-of-string searching that the original "View Unit" dialog offers)!

PatrickvL
+2  A: 

If you have GExperts installed (and you should), you can press [Control] + [Shift ] + [f] while the cursor is on some component's name, in the source code, and the component will be selected in the form. Very useful.

+1  A: 

Ctrl + E -> incremental search. In case you find "Ctrl+F" with the dialogue too much of an hassle.

utku_karatas
+3  A: 

Code folding:

  • Ctrl+Shift+K+A Expands All blocks of code
  • Ctrl+Shift+K+E Collapse current block of code
  • Ctrl+Shift+K+U Expand current block of code
  • Ctrl+Shift+K+T Toggle Current block (expand & collapse)
  • Ctrl+Shift+K+R Collapses all regions {$region 'comment'}..{$endregion}
  • Ctrl+Shift+K+P Collapse nested procedures
  • Ctrl+Shift+K+M Collapse all methods
  • Ctrl+Shift+K+C Collapse all classes
  • Ctrl+Shift+K+G Collapses down to primary Groups [Interface/Implementation]
  • Ctrl+Shift+K+N Collapses Namespace/Unit

This and others shortcuts in a little unknown wiki.

eKek0
+1 for the wiki ref
borisCallens
+2  A: 

The command line switch -np starts Delphi without loading the last used project.

Francois Zbinden
add -ns for "no splash screen" and it improves the startup time noticeably.
JosephStyons
+4  A: 

In the editor, you can hold down the alt key and drag select to perform a block selection.

SeanX
+1  A: 

Ctrl+Arrows moves control one pixel.

Ctrl+Shift+Arrows moves control several pixels.

Another nice feature is Sync Edit Mode, invoked by selecting several rows and pressing ctrl + shift + j (or clicking the icon that appears on the left). This allows you to change all instances of the same text at once, e.g. variable names, function calls...

johnny
A: 

Open a new edit window with the View / New Edit Window menu item. This is particularly useful if you have a second monitor on which you can put the new edit window.

dangph