Turn workspace-relative file paths in source-code comments into native links in Visual Studio Code.
Features
- Ctrl+click on Windows and Linux, or Cmd+click on macOS, to open a linked file.
- Open File and Open to the Side actions above each valid link.
- Directory and file suggestions while typing a path.
- Works in any file-based editor and with text, images, PDFs, and other file types supported by VS Code.
- Supports multi-root workspaces by resolving a link from the workspace folder that contains the current document.
- Rejects paths that escape the workspace.
Syntax
Use FILE-LINK:/ followed by a path relative to the workspace root:
// FILE-LINK:/README.md
//! FILE-LINK:/database/migrations/users.sql
# FILE-LINK:/docs/architecture.md
LINK:/ from the original extension remains supported for compatibility, but new links should use FILE-LINK:/.
Path suggestions
Type the prefix and the first slash:
// FILE-LINK:/
Visual Studio Code suggests directories and files from the workspace root. Selecting a directory inserts the trailing slash and opens suggestions for the next level. You can also press Ctrl+Space to request suggestions manually.
Paths containing whitespace are not supported in version 1.0.0.
Opening a link
- Hold Ctrl on Windows or Linux, or Cmd on macOS, and click the path.
- Select Open File in the CodeLens above the comment.
- Select Open to the Side to keep the current file visible.
The modifier used for native links follows your VS Code mouse settings.
Development
npm install
npm run compile
npm run package
npm run package:vsix
Acknowledgements
Comment File Links is based on Link to File by Göksel Darcan. The original MIT copyright notice is preserved in the included LICENSE.md file.
License
MIT