Delphi Productivity Tips: Navigation Toolbar
At the top of Delphi's code editor, is a Navigation Toolbar with several "jump lists" as I like to call them. They help you find and jump to places in your code quickly by selecting them from lists built by the parsing engine in Delphi. There are also shortcut keys that allow you to use them without taking your hands off the keyboard to use the mouse.
Navigating Types and Methods
The red boxed area of the image above shows the Navigation Toolbar with a loaded unit from the Graphics32 open source project. The highlighted line in the editor is the
LoadFromStream procedure of the
TCustomBitmap32 class, both shown in the toolbar. Notice the little drop-down arrows just to the right of them? Those present a scrollable list of types and methods in the current unit.
For example, let's say I want to see what other
Load... methods there are; clicking the down-arrow button just to the right of
TCustomBitmap32.LoadFromStream in the toolbar, shows an alphabetical list of methods and I can quickly see there are also methods named,
LoadFromResourceName; clicking on one takes me immediately to its implementation body. Similarly, I can quickly scan through the list of types with the button next to
TCustomBitmap32 to jump to their declaration. Both of these lists support incremental searching to help filter the results down, providing very quick navigation around your code.
There are shortcut keys so you don't have to use the mouse if you like keeping your hands on the keyboard. They use a combination of keys, all starting with Ctrl+Alt+N (for "Navigation"); the Types list can be activated with
Ctrl+Alt+N and Ctrl+Alt+T (for Types) and the list of procedures and functions are activated with Ctrl+Alt+N and Ctrl+Alt+P (for Procedures, I guess). Both of these shortcut combinations are only activated while in the code editor.
There are two buttons to the left of the Types drop-down list--let's look at those.
Navigating Units and Sections
The far left button in the Navigation Toolbar shows a list of units used by the current unit in the editor. There are two columns: the left-side column shows units used in the
interface section and the right-side column shows units used in the
implementation section of the current unit. Clicking on one of the units loads it into the editor. The keyboard shortcut is Ctrl+Alt+N and Ctrl+Alt+U (for Units).
The button between the Units button and the Types list presents a list of unit sections. This is mostly the same for each unit except when one or both of the
uses clause is missing. This list makes it handy to jump to the top or bottom of the file (if you don't remember the shortcut keys Ctrl+Home or Ctrl+End), or to either the
implementation section quickly. If you don't have the Navigator plugin, use this to quickly jump to the
implementation uses section. To quickly access this list without the mouse, hit Ctrl+Alt+N and Ctrl+Alt+S (for Sections).
There's one more, often overlooked, button on the Toolbar that let's you search for your project-specific identifiers.
Last but not least, there's a little search icon (magnifying class) on the right side of the Navigation Toolbar. Selecting this pops open an empty list with an incremental search box for finding project symbols. This will not include keywords or identifiers defined in by Delphi's RTL but only symbols your project declares. But it does more than just find its declaration, it also shows you all instances with the line numbers and filenames--and lists the total number of places it found at the bottom of the list. Once you select the instance of the symbol to go to with the arrow keys or the mouse, it will take you to that spot in the file indiciated. To get to this list with the keyboard, use Ctrl+Alt+N and Ctrl+Alt+F (I imagine "F" was used to represent Find).
I have found these useful and as I was typing up this article discovered more features of the Navigation Toolbar than I had known about previously--and I'll use it more now. I hope you find it useful as well--if you don't, you can always turn off this set of navigational aids entirely by going to Tools > Options > Editor Options > Display and unselect "Show Navigation Toolbar."