VSCode extension that copies selected lines or ranges together with their line numbers. The copied content can be formatted either as plain text or as a Markdown fenced code block, making it easy to share precisely referenced snippets.
- Copy every line that intersects the current selection (or cursor) with aligned line numbers.
- Copy only the selected text range with aligned line numbers.
- Toggle between plain text and Markdown output formats via the extension setting.
- Editor context menu entries and optional keyboard shortcuts for quick access.
- Localized status messages (English, Japanese, Simplified Chinese, Korean).
| Command ID | Title | Description |
|---|---|---|
extension.copySelectedLines |
Copy Selected Lines With Line Numbers | Copies whole lines that intersect the current selections. When nothing is selected, the command uses the cursor lines. |
extension.copySelectionRange |
Copy Selection Range With Line Numbers | Copies only the highlighted ranges. The command is unavailable when no selection exists. |
| Setting | Type | Default | Description |
|---|---|---|---|
copyWithLineNumbers.outputFormat |
string |
markdown |
markdown outputs a fenced code block ( ```relative/path). plain outputs a plain text header (File: relative/path). |
- macOS:
cmd+shift+ctriggersextension.copySelectedLines. - Windows:
ctrl+shift+ctriggersextension.copySelectedLines. - Additional shortcuts can be customized via VSCode's Keyboard Shortcuts preferences.
- Select one or more ranges in the editor (or place cursors).
- Open the context menu and choose either:
- Copy Selected Lines With Line Numbers
- Copy Selection Range With Line Numbers
- Paste the clipboard into your target document. The line numbers are right-aligned to the width of the largest line number in the selection.
When the output format is markdown, the snippet is wrapped as:
```relative/path/to/file.ts
9: console.log('Hello');
10: console.log('World');
```npm install
npm run compileTo run the extension in a VSCode Extension Development Host:
- Press
F5in VSCode (or use the “Run and Debug” panel). - In the dev host window, open a file and execute the provided commands.
- Install the VSCode Extension Manager if you have not already:
npm install -g @vscode/vsce
- Update the
publisherfield inpackage.jsonto match your Marketplace publisher name. - Generate a package:
vsce package
- Publish the extension:
vsce publish
See LICENSE.