Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Path Go To DefinitionNew to Visual Studio Code? Get it now.
Path Go To Definition

Path Go To Definition

ascpixi

|
3,471 installs
| (0) | Free
Extends the "Go to Definition" (F12) action to support file paths in strings
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Path Go To Definition VSCode Extension

Extends the "Go to Definition" (F12) action to support file paths in strings, with extensive customization abilities.

(GitHub | Issue Tracker)

Extension demonstration

Features

  • language-agnostic,
  • ability to define regular expressions to match custom path formats in strings,
  • ability to define custom settings depending on the language ID of documents and by matching their pathnames via regular expressions.

Extension Settings

This extension contributes the following settings:

  • pathGoToDefinition.projectRootRegex: The regex to use when checking for paths that are relative to the project's root directory. Matches the whole string.
  • pathGoToDefinition.relativeRegex: The regex to use when checking for paths that are relative to the directory the file is in. Matches the whole string.
  • pathGoToDefinition.langWhitelist: Language IDs that the extension should handle. If empty, all languages are handled.
  • pathGoToDefinition.filenameWhitelist: If any of the regex patterns in the array match the relative path of a document, the extension will be active for that document. If empty, no checks are performed.
  • pathGoToDefinition.specific: Allows for specialized configuration sets for different languages or file types.

The pathGoToDefinition.specific setting is an array of objects of the given types:

  • language: The language ID that this specific configuration set matches. (string or null)
  • path: The regular expression to match against the file path to determine whether this configuration set applies. (string or null)
  • projectRootRegex: The regex to use when checking for paths that are relative to the project's root directory. Matches the whole string. If null or empty, uses the global default. (string or null)
  • relativeRegex: The regex to use when checking for paths that are relative to the directory the file is in. Matches the whole string. If null or empty, uses the global default. (string or null)
  • pathStringRegex: The regex to use when scanning for path strings in addition to regular string scanning. The last group is used as the string. Matches the entire line. If null or empty, this behavior is disabled.
  • defaultFile: If a path points to a directory, the extension will navigate to the file with this name in that directory. (string or null)
  • assumedProjectRoot: Paths detected with this configuration set will assume this path as the project root. This path may itself be relative to the real project root.

The defaults for these settings are:

Name Default Default (JSON)
pathGoToDefinition.projectRootRegex ^(?:\/|\\).+$ "^(?:\\/|\\\\).+$"
pathGoToDefinition.relativeRegex ^\.(?:\/|\\).+$ "^\\.(?:\\/|\\\\).+$"
pathGoToDefinition.langWhitelist (empty) []
pathGoToDefinition.filenameWhitelist (empty) []
pathGoToDefinition.specific (empty) []

The pathGoToDefinition.specific can prove useful when defining support for e.g. DSLs based on another language. For example:

{
    "pathGoToDefinition.specific": [
        {
            "language": "python",
            "path": "^.+\\.build$",
            "defaultFile": "component.build",
            "projectRootRegex": "^.+\\/.+$"
        }
    ],
}

This snippet will apply to all files that are classified to be Python and that have their pathnames end with .build. The project root regex is changed to be less restrictive (only requiring a single slash in a string to be considered a path), and instruct the extension to go to the component.build file if the path points to a directory.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft