VSCode Copy Markdown Link
A Visual Studio Code extension that allows you to copy a markdown-formatted link to the current file and cursor position.
Installation
Install from the Visual Studio Code Marketplace or Open VSX Registry.
Features
- Copy Markdown Link: Copy a link to the current file and line in markdown format.
- Customizable Templates: Use template variables to create your own link format.
- Editor Support: Choose between
vscode (default), cursor, and antigravity editors.
Usage
- Place your cursor on the line you want to link to.
- Open the Command Palette (
Cmd+Shift+P / Ctrl+Shift+P).
- Run "Copy Markdown Link: Copy".
Example Output
For a file at src/utils/helper.ts line 42 in a Git repository:
helper.ts#L42([github](https://github.com/user/repo/blob/main/src/utils/helper.ts#L42)/[vscode](vscode://file/absolute/path/to/src/utils/helper.ts:42))
Extension Settings
This extension contributes the following settings:
copyMdLink.editor: Select the editor for local links. Options: vscode (default), cursor, antigravity.
copyMdLink.template: Customize the markdown link format using template variables.
Template Customization
You can customize the output format using the copyMdLink.template setting. The default template is:
{fileName}#{lineNumber}([github](https://github.com/bisquit/vscode-copy-mdlink/blob/HEAD/{gitHubLink}) / [{editor}](https://github.com/bisquit/vscode-copy-mdlink/blob/HEAD/{editorLink}))
Available template variables:
{fileName}: Name of the current file (e.g., helper.ts)
{lineNumber}: Line number or range (e.g., L42 or L14-L17)
{gitHubLink}: GitHub URL to the file and line (empty if not in a git repository)
{editor}: Editor name (vscode, cursor, or antigravity)
{editorLink}: Local editor protocol link
Template Examples
Simple file and line reference:
"copyMdLink.template": "{fileName}:{lineNumber}"
Output: helper.ts:L42
GitHub link only:
"copyMdLink.template": "[{fileName}#{lineNumber}](https://github.com/bisquit/vscode-copy-mdlink/blob/HEAD/{gitHubLink})"
Output: [helper.ts#L42](https://github.com/user/repo/blob/main/src/utils/helper.ts#L42)
Custom format with emoji:
"copyMdLink.template": "📄 {fileName} 📍{lineNumber} | [GitHub](https://github.com/bisquit/vscode-copy-mdlink/blob/HEAD/{gitHubLink}) | [Open in {editor}](https://github.com/bisquit/vscode-copy-mdlink/blob/HEAD/{editorLink})"
Output: 📄 helper.ts 📍L42 | [GitHub](https://github.com/...) | [Open in vscode](vscode://file/...)
Requirements
- VS Code 1.104.0 or higher