Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CLion code navigation with C++ doesn't work

I've used AppCode (Intellij C++/ObjC IDE that replaces Xcode) for a while and really gotten used to being able to Ctrl+Click on any identifier to get to its definition/decleration.

Now on a new work place, I'm using CLion for a somewhat larger code base and Ctrl+Click hardly ever works. It only seem to work when the identifier is in the same file.

Is there anything I need to setup for this to work correctly? CLion seem to index the code successfully and doing text searches works fine.

like image 387
shoosh Avatar asked Jun 19 '18 08:06

shoosh


2 Answers

You need to press ctrl + alt + shift + n.
And after pressing it a dialog box will appear to enter your variable/function name and click enter. Tip: Filter the result for a better experience. Filter option is present on right side of the dialog box.


To get a quick peek of function/variable definition press ctrl + q while focusing on the variable or function.

To get the detailed or full definition of function press ctrl + shift + i while focusing on the variable or function.

like image 64
hermes Avatar answered Sep 20 '22 19:09

hermes


You need to use import project functionality of CLion from File -> Import Project and give ok for CMakeLists.txt file automatic creation. Never mind the file is for CMake, you can build your project with other tools too, but CLion uses it for the dependencies.

Then append in the beginning of that file a line stating:

include_directories(.)

After that go to File -> Settings and there search for Keymap from the left and after that on right, right below the word "keymap" there is a selection element for taking for example Eclipse default keymapping in use and there you have at least (I tested only it) the ctrl + click functionality working like charm!!

kudos about the include_directories(.) goes to this question: CLion indexer does not resolve some includes in the project directory

like image 33
mico Avatar answered Sep 21 '22 19:09

mico