How to go to function definition in Visual Studio, with using shortcut F12, Ctrl and not working

Lionsure 2020-09-18 Original by the website

If a project has many layers and the reference relationship of classes is complicated, it is very troublesome to find the upper class or top-level base class; fortunately, some development tools provide the function of searching for these classes, which makes the troublesome things easier. With the upgrade of the Visual Studio, starting from Visual Studio 2015, Javascript has also added "Go to Definition", and quickly find a reference method.

 

I. How to go to function definition in Visual Studio(Visual Studio find class)

1. Quick steps:

Right click "base class" → go to definition → automatically open the file where the base class is located and locate the base class.

 

2. Detailed steps:

Right-click on the base class(GenerateRandom), select "Go To Definition" in the pop-up menu, then the file where the base class(GenerateRandom) is located will be opened automatically and the location of "GenerateRandom: will be located. As shown in Figure 1:

How to go to function definition in Visual Studio

Figure 1

 

3. Go to definition shortcut Visual Studio

1) F12. Select the method name(GetRandomDoubleNumber) or position the cursor in the middle of "GetRandomDoubleNumber"(after G before r), press F12 to locate the referenced method, the demonstration is shown in Figure 2:

Go to definition shortcut Visual Studio

Figure 2

 

2) Ctrl(Visual Studio ctrl click go to definition). Hold down the Ctrl key, move the mouse to the method name(GetRandomDoubleNumber), the "GetRandomDoubleNumber" turns blue and underlined, click the left button of mouse to locate the referenced method, as shown in Figure 3:

Visual Studio ctrl click go to definition

Figure 3

 

4. VS Javascript go to definition(VS2015 and above)

Right-click the method name "checkPwd", select "Go To Definition" in the pop-up menu, go to the referenced method, the demonstration is shown in Figure 4:

VS Javascript go to definition(VS2015 and above)

Figure 4

 

5. Shortcut key for going back to after going to definition(Visual Studio F12 go back)

After going to the definition, press Ctrl + - to go back. Note: press - on the small keyboard does not work, you have to press - on the big keyboard.

 

 

II. Go to definition not working in Visual Studio

1. The solution of the "Go To Definition" turns gray

1) The "Go To Definition" turns gray in Visual Studio C++

This problem is usually that the "disable database" is not set to "false", just set it to false. The method is: Tools → Options → Text Editor → C/C++ → Advanced, set "Disable Database" to "false", close the project and reopen it.

 

2) The "Go To Definition" turns gray in Visual Studio

A. First unload and reload the project whose "Go to Definition" turns gray. If not, unload all projects and reload.

B. Close Visual Studio, navigate to C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files(v4.0.30319 can also be v2.0.50727), delete all files and folders inside, and open the project, just regenerate the solution. This method can also be used to the "Go To Definition" that has disappeared.

 

2. The solution that the "Go To Definition" cannot be used

1) Go to definition not working in Visual Studio

Regenerate all the projects, if not, then unload all the projects and reload.

 

2) Visual Studio failed to go to definition

This situation usually occurs after Visual Studio is upgraded. Just close Visual Studio, then delete the files with the extensions VC.db and sdf in the "solution" directory or delete all files in "bin and obj", and then reopen Visual Studio.