1. Home
  2. Computing & Technology
  3. Delphi Programming
Code Navigation in Delphi
How to be even more productive with Delphi IDE (precisely, the code editor): start using code navigation features - quickly jump from a method implementation and a method declaration, locate a variable declaration using tooltip symbol insight features, and more.
 More of this Feature
Printer friendly versionPrinter friendly version
 Join the Discussion
"Post your views and comments to this chapter of the free Delphi Programming Course"
Discuss!
 Related Resources
• A Beginner's Guide to Delphi Programming.TOC

• Code completion in Delphi
• Delphi IDE articles
• OOP in Delphi
• Top Delphi Add-On
 Elsewhere on the web
• Delphi editor Keyboard shortcuts

Welcome to the eighteenth chapter of the FREE online programming course:
A Beginner’s Guide to Delphi Programming.
How to be even more productive with Delphi IDE (precisely, the code editor): start using code navigation features - quickly jump from a method implementation and a method declaration, locate a variable declaration using tooltip symbol insight features, and more.

How to code faster and more efficiently - "take two"
Back in the thirteenth chapter of this Course, we've discussed using Delphi IDE's features like code templates, code insight, code completion...

I hope you are using all those great code editor features every day. However, how many times were you scrolling the code editor window just to find one method's implementation? How about having more than one class declaration in the interface section - how fast can you locate the class implementation?

The answer is: Delphi Code Editor Navigation!

Code Explorer
When you work on a project, you need to navigate around the source code for that entire project, including tracing calls into various units comprising the project. Delphi includes a great tool called the "Code Explorer" (docked to the left of the Code editor), which enables you to navigate through your unit files. The Code Explorer represents a project unit's in a tree-like diagram that shows all the types, classes, properties, methods, global variables, and global routines defined in a unit. If you cannot see the Code Explorer window in the Code editor, make it visible by clicking on View-Code Explorer menu item in the main Delphi IDE. Here are the icon descriptions:

Delphi Code Explorer Delphi Code Explorer icons

When you select an item in the Code Explorer, the cursor moves to that item's implementation in the Code editor.

Once you are "inside" the code, you could be tempted to jump to the item's declaration in the interface section. This is where code (or module) navigation comes handy.

Code Browser, Code Navigation
The most common way to navigate your unit's source is with the mouse and navigation keys. While you are working your way through the unit, additional tools called Code Insight help with coding. Code insight feature displays declaration information for any identifier by passing the mouse over it in the Code editor.

Delphi code insight

Delphi code browsing Delphi code browsing

Now try this: hold down the Ctrl key and move the mouse over an identifier. It will turn into a hyperlink, and the mouse cursor will turn into a pointing hand. Clicking on the hyperlink will take you to the identifier’s declaration. You get the same effect by choosing Find declaration from the editor's context menu, or by hitting the Alt + UpKey key combination.

Note: you can even browse through the VCL source is you Delphi version has one.

Module Navigation
And finally, here's my favorite:
While working on a method's code, hit the Ctrl + Shift + DownKey or Ctrl + Shift + UpKey to jump between the method declaration (interface section) and implementation.
This keystroke combination comes very handy when used with class completion.
Some exercises for you...
Hmm, simply start using Delphi code navigation features, you will not believe how much time you can save in coding, and of course you can drastically reduce the number of bugs in your code.

   To the next chapter: A Beginner's Guide to Delphi Programming
This is the end of the thirteenth chapter, in the next chapter, we'll deal with ... well I don't know yet...

If you need any kind of help at this point, please post to the Delphi Programming Forum where all the questions are answered and beginners are treated as experts.

A Beginner's Guide to Delphi Programming: Next Chapter >>
>> The TOC

Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming

©2009 About.com, a part of The New York Times Company.

All rights reserved.