Delphi IDE: Folding and Next Error from the keyboard
I wish one of the CodeGear bloggers would blog about new keystrokes they’re adding to the IDE with each new version. Once I finally managed to dig up the Help for keyboard shortcuts (such as it is), I found some that I never knew about. Put these in some RSS, man!
Better yet: I wish one of the CodeGear bloggers would blog about new keystrokes they’re thinking about adding, before they actually add them, so there’s some sort of comment period. These keystrokes are atrocious! Honestly, Ctrl+Shift+K T? Think about the amount of finger travel on that one, as your left hand has to move from the farthest left it can go (to hold down Ctrl and Shift) to the farthest right it can go (to press T). Seriously, somebody needs to be publicly flogged for that one.
So here are some keystrokes you probably never knew about. Did you know you can (allegedly) control code folding from the keyboard? And that Delphi actually has a keystroke to jump to the next compiler error?
Here are the most important code-folding keystrokes (Expand All, Collapse All, and Toggle Current, the only ones I’ve ever seen anyone actually use):
- Toggle Current: Ctrl+Shift+K T.
- Expand All: Ctrl+Shift+K A.
- Collapse All: They make this one painful; you have to specify what you want to collapse.
- Collapse all classes: Ctrl+Shift+K C.
- Collapse all methods: Ctrl+Shift+K M.
- Collapse namespace/unit: Ctrl+Shift+K N.
- Collapse nested procedures: Ctrl+Shift+K P.
- Collapse regions: Ctrl+Shift+K R.
Note that none of the code-folding keystrokes seem to actually do anything at all, but those are the keys you’re supposed to have to hit, according to the documentation.
And here are the keystrokes for jumping to the next compiler error. They’re also rumored to work for Find in Files results, if you use that instead of GExperts Grep. (And I do, on rare occasions, since Delphi’s regular expression support sucks less than GExperts’, as long as you have the Delphi 6 Help files where Delphi’s goofy regex syntax was actually documented.)
- Next error / next item in Messages window: Alt+F8.
- Previous error / previous item in Messages window: Alt+F7.
Note that the “next / previous error” keystrokes aren’t actually documented (at least in Delphi 2006); the only way I was able to find out about them was to file an enhancement request, and then read the reason why it was closed. (Although later I did find them included in a list of interesting, and mostly undocumented, Delphi IDE keystrokes.)
The Twister award, for most useful yet most contorted keystroke, would have to go to Ctrl+Shift+K T, if it worked. But these are all pretty lousy. Alt+Function key, for something you would do repetitively? Eww. Couldn’t CodeGear take a page from ReSharper, and make the most-used keystrokes easier to type?
April 21st, 2007 at 2:35 pm
Hey Joe,
Just FYI, the error message keys have been on my keyboard chart for years. You may find others you’ve missed as well. Here is the chart:
http://www.stevetrefethen.com/wiki/Keybinding%20Information.ashx
I also mention a number of keystrokes related to code completion in this video which you might find useful:
http://www.stevetrefethen.com/files/codecompletion.html
As for the code folding keys I’ll look to add those to my chart.
The likely reason something like Ctrl+Shift+K T was used is because we’re pretty much out of short key combinations. Personally, I _never_ use code folding and I imagine we haven’t heard much about it’s keyboard support because most people don’t use it either. Regardless, perhaps it’s time to refactor some of the lesser used ones.
April 21st, 2007 at 5:14 pm
Codegear could do a lot more to help - BDS versions and later should put the shortcut key (no matter how contorted) in the tooltips. Case in point: Ctrl-Alt-P should be displayed when you hover over the Filter icon above the tool palette - it took me ages to work it out after I saw somebody using it in a demo.
April 21st, 2007 at 7:08 pm
2 Notes: 1st, there *are* shortcuts for Collapse All, but they work on some items at a time!
Ctrl+Shift K+C Collapses all classes
Ctrl+Shift K+M Collapses all methods
Ctrl+Shift K+N Collapses namespace/Unit
Ctrl+Shift K+P Collapses nested procedures
Ctrl+Shift K+R Collapses all regions
Also noteworthy for some:
Ctrl+Shift K+O Toggles between enabling and disabling Code Folding
2nd note: Delphi 2007’s help files for these seem to have been copied as is from BDS 2006 as they too miss those keys you mention in that QC report…
April 21st, 2007 at 9:02 pm
Fernando, thanks for pointing those out. I’ve updated the post to reflect them.
I’ve also actually *tried* them, and none of the code-folding keystrokes do a darned thing. I’ve updated the post to reflect that, as well…
April 24th, 2007 at 11:45 am
Hi Joe,
I tried the code-folding keystrokes and they seem to work. ???
Nice website.
John E
April 24th, 2007 at 4:28 pm
Bizarre. The code-folding keystrokes do absolutely nothing in Turbo Delphi.