Go to definition
Hi!👋 This is a community-driven, beta document, NOT an official GitHub document. Your contribution to make this even better is super welcome!🚀 Please dive in and contribute🙌

Go to definition #

GitHub Copilot will not read all codebases as of August 2023, so there will be occasions when this technique will be necessary. On the other hand, there is a possibility that in the near future this technique will no longer be needed in GitHub Copilot, and this technique may be very limited.

Description #

When working with a complex codebase, jumping between files or searching through layers of code to find the definition of a particular symbol can be cumbersome. “Go to Definition” is a useful feature in Visual Studio Code that allows developers to quickly navigate to the definition of a symbol in the current file. This not only enhances productivity but also enables better understanding of the code structure. GitHub Copilot will read open tabs. So, you can also pass relevant code snippets related to the symbol definition to GitHub Copilot

Example #

To use the “Go to Definition” feature in VS Code, simply right-click on the symbol you want to explore and select “Go to Definition.” You can also use the shortcut F12. Here’s how you can do it:

Exerecise #

  • Exercise 1: Open a project with multiple files in Visual Studio Codeand try to use “Go to Definition” to navigate to a class or function definition.
  • Exercise 2: Practice using the “Go to Definition” feature with different symbols such as variables, methods, or classes to understand its versatility.

Checklist for Further Learning #

  • How does the “Go to Definition” feature enhance your overall coding experience?
  • How can GitHub Copilot’s integration with the “Go to Definition” feature be used to further assist you in code navigation and understanding?
  • Can you identify situations where this feature could be exceptionally useful in your development workflow?