'Is there a way to navigate to a function's definition in another file in VSCode or CLion for CPP?

I am working in a project where I am on a specific file in a folder, the structure is like this:

└─project_folder/
    ├─ myFile.cpp
    └─ other_folder/
        ├─ headerFile.h
        └─ otherCppFile.cpp

Now I have a function createBoundary() in myFile.cpp, there are a lot of header files in myFile.cpp and I am not sure where the function is declared/defined. Is there a way to navigate to the function createBoundary()'s definition in VSCode or CLion? I have already tried doing that by going to options and clicking "Go to definition" but that didn't work and it only gave me a popup saying "No definition was found".

PS. If the above said thing is not possible in both the mentioned IDEs and there's another IDE which facilitates that, do let me know please.



Solution 1:[1]

Using the command Ctrl + P or Command + P you can input the fileName and navigate to a file in VSCode (plus, it has some advanced features).

Now if you write myFile or myFile.cpp you can open the myFile.cpp and it also works for directories. writing components/index in the input takes you to somewhere where the folder's name is components and opens a file named index which is located inside of the components folder

If you write myFile:122 it takes you to the file myFile.cpp and line 122. Now if you write myFile.cpp@createBoundary it opens the file myFile.cpp, finds whatever value or function or anything that has the name createBoundary and puts the cursor on it.

If the createBoundary is inside of another object or function, you can use myfile.cpp#createBoundary. So you don't have to navigate all the way down to the corresponding line of code.

By the way, when you've already opened the file, you don't need to write the fileName anymore, just #createBoundary or @createBoundary or :122 is enough that time.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1