Link Search Menu Expand Document

Jump to Definition

Jump to Definition (Go to definition) is provided for BUILD file labels (typically, this is mapped to the keyboard shortcut F12).


Jump to definition has the following “best-effort” semantics:

  • If the label represents a source file (e.g. //:main.go), open at the beginning of the file.
  • If the label represents a rule (e.g. //:myrule), open the BUILD file at the corresponding rule definition.
  • If the rule cannot be found within the BUILD file, no action is taken.
  • If the label is in an external workspace (e.g. @foo//:bar), open the file/rule in the external workspace foo. This behavior requires that the bazel server for the repository be running.

Copy Label To Clipboard

Jump-to-label has a variant that, rather than opening the BUILD file at the target, copies the label to the clipboard. This can be triggered by the Bazel: Copy Label to Clipboard command menu item, the (right-click) context menu while inside a BUILD file, or via the keybinding (by default shift+ctrl+command+b).

Copyright © 2020 Stack.Build.