Skip to content
BENIBIX Learn

Go to Definition

Development🕸️ Code IntelligenceCode Navigation

Also known as Jump to Definition, Go to Declaration, F12 (Go to Definition)

An editor command. It jumps from a name to the place where it is made.

Think of it like

It is like tapping a word in a book. You land on the page that says what it means.

Example

In Visual Studio Code, Jack puts his cursor on sendInvoice and presses F12. The editor opens billing.ts at the line that defines it.

Why it matters

It turns reading a new codebase from a hunt into a walk. One key press replaces a search.

Definition

Go to definition is an editor command that jumps from a name to where it is made. You click on a function call, and the editor opens the file and line where that function is written. It works for classes, variables and types too. The editor gets the answer from a language server or a code index. It is the most used way to find your way in code you did not write.
The editor sends go to definition as a question. The server sends back a file and a line.

Common mistake

Landing on a type file, not the real code. In some languages the first hit is just a stub, so look for go to implementation too.

Key takeaways

  1. 1
    From use to source. Jump to where it is made.
  2. 2
    Needs an index. A server or index gives the answer.
  3. 3
    Works both ways. Pair it with find all references.