Category
I've been watching a weekly webinar by Embarcadero, usually hosted by Jim McKeeth, called TCoffeeAndCode and today's topic was "Managing Large Projects and IDE Performance Enhancements". This one was packed full of tips and tricks for speeding up your development with IDE plugins, better use of the keyboard, managing projects, analyzing code, and so forth. Near the end, Jim called out to programmers everywhere to blog about their favorite productivity tips and share with others what works for them to speed up software development.
So I'm taking on this challenge for myself and am starting a mini series highlighting ways I use Delphi, the short-cuts I've found useful, my favorite plugins, and other tidbits I've picked up along the way. Perhaps you will find something useful. In this first blog on the topic, I'll talk about the built-in keyboard shortcuts Delphi provides in the editor and how I use them every day.
Editing
- Ctrl+Shift+C: Class Completion. This handy shortcut is used when building out a class and you've just entered either a property or a method in the interface section. Hit this and fields will be created for properties and method bodies will be created for procedures or functions with the cursor placed inside the first one. If your property uses getter and setter methods instead of fields, then those method interfaces are created as well as their implementation.
- Ctrl+Shift+↑ or Ctrl+Shift+↓: Jump between the interface delcaration and the implementation of a method. Both shortcuts do the same thing.
- Ctrl+Shift+Alt+P: Sync Prototypes. How often to you make a change to the parameter list of a class method? I do it frequently as I realize I need to add more information or combine parameters or sometimes just change the name or type of a parameter. This handy shortcut keeps the interface's declaration and the implementation's parameters the same--and the change can be made in either place.
- Ctrl+Shift+I, Ctrl+Shift+U: Indent and Un-Indent a block of code by your defined tab amount.
- Ctrl+Space: Code Completion: Use incremental typing to quickly find and complete typing of various identifiers and code constructs.
Ctrl+Shift+Space: Parameter Completion: when you're typing parameters in a method call and can't remember all the parameters or what order they're in, use this inside the parenthesis to display a hint below the line you're typing.
- Ctrl+W: Select nearest block; repeat for increasingly larger blocks. I often forget about this very nifty shortcut for selecting blocks of code. If you're in a while-do or if-then or any kind of block, instead of moving the cursor to the beginning of the block, holding shift, and navigating to the end of the blog, just hit Ctrl+W a few times until the block you want is selected. Hit it a few more times and you've selected the entire method. Very handy!
- Shift+Ctrl+1..9, Ctrl+1..9: Toggle a numbered bookmark and Go to a numbered bookmark. Let's say you have three places in your code you visit frequently; navigate to the first one, hit Shift+Ctrl+1, navigate to the second and hit Shift+Ctrl+2, and the third with Shift+Ctrl+3. Then you can bounce between them using Ctrl+1, Ctrl+2, and Ctrl+3. To clear a specific bookmark, go to that bookmark and click Shift+Ctrl+# (use the bookmark number) to toggle it off. Delphi helps you from accidentally moving a bookmark by warning you that one is already set if you try to set it again; in that case, simply set it twice to tell Delphi you want to move it anyway.
Debugging
- F9: Start the application with debugging.
- F5: Set a breakpoint to pause program execution while debugging.
- F4: Run the application to the cursor point and pause execution without setting a break point.
- F7, F8: Step through execution one line at a time, stepping into methods (F7) or running a whole method as if it were one line of code (F8).
- Shift+F8: If you're stepping through a method, this will run to the end of the method then pause execution.
- Ctrl+F2: Stop debugging and halt execution of the application.
- Ctrl+Shift+F9: Start the application without debugging.
These are the basic ones I use often but there are so many more. In the next blog I'll talk about one of my favorite Delphi editor features: Live Templates.
Add new comment