When working with large projects, it’s often beneficial to be able to quickly locate files and folders, as well as types and their members. It is also very helpful to be able to quickly visualize and navigate inheritance hierarchies as well as include dependencies. This is precisely what IDEs are made for, and CLion is no exception. Here is an overview of some of the navigation facilities that come with CLion.
Go To Actions
CLion comes with several quick navigation actions available with their respective shortcuts (given here for Windows and Linux, as well as for OS X for the cases it differs from Windows and Linux one). These include
- Go to Class (
⌘O) takes you a particular type
Notice how you don’t need to enter the full type name – just a few letters are enough to find something. Also, it’s possible to press
⌘Oonce again to have the search include files which are not part of the project as such.
- Go to File Name is invoked with
⇧⌘Oand, as the name suggests, this takes you to a particular file.
One thing to note is that you don’t have to use a proper substring to search on. For example, typing the letters cml will locate the
- Go to Symbol, invoked with
⌥⌘O, locates a symbol, whether it is the name of a type or type member.
One neat way of visualizing the contents of the file you are currently in is the File Structure window. This gives you a tree-like presentation of all the structures (classes, members, nested classes, etc.) in a file. CLion supports two-way synchronization, so selecting the item in the tree takes you to the corresponding place in the code, and vice versa:
You can bring up this tool window by pressing
⌘F12. Please note that it only supports structured code files.
CLion comes with plenty of navigation options when you’ve got the cursor on a particular code element. First, there’s Navigate to Related Symbols (
^⌘↑) — this does exactly what the name suggests, meaning that if you’re on a function declaration, for example, it will take you to the definition.
CLion also has a shortcut in case you want to Navigate to Declaration (
⌘B). You can also Navigate to Super Definition to jump up the inheritance hierarchy.
Another useful tool window is the Type Hierarchy window, which shows an inheritance hierarchy for a particular type:
This hierarchy window can be shown with
Ctrl+H, and can show either all the descendants or all the parents (which is helpful when multiple inheritance is concerned).
Another type of hierarchy that CLion knows how to illustrate is the Imports Hierarchy (
Alt+Shift+H), usable for quickly browsing the chain of includes that a particular header file brings.
Yet another type of hierarchy window is the Caller/Callee Hierarchy (
Ctrl+Alt+H), which illustrates who exactly calls a particular function. The hierarchy illustrates all the call chains as a tree that you can navigate:
Recent Files and the Switcher
To navigate to any of the currently open files in the solution, simply press
Ctrl+Tab. Similarly, to navigate to any of the recent files you’ve been working with, press
⌘E. Both of these windows use the Switcher mechanism:
Note the elements on the left: selecting them will open up the corresponding tool window. The entire list can be scrolled forwards and backwards with
To quickly go through the errors in a project, you can press
F2 to Go to Next Highlighted Error, and
Shift+F2 to go back.
Watch CLion search and navigation features in action:
If you haven’t seen CLion already, grab the EAP build and give it a go! ■