Skip to content
yucjk0120Public

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Copy Selected Code With Line Numbers

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.

Features

  • 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).

Commands

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.

Settings

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).

Keybindings

  • macOS: cmd+shift+c triggers extension.copySelectedLines.
  • Windows: ctrl+shift+c triggers extension.copySelectedLines.
  • Additional shortcuts can be customized via VSCode's Keyboard Shortcuts preferences.

Usage

  1. Select one or more ranges in the editor (or place cursors).
  2. Open the context menu and choose either:
    • Copy Selected Lines With Line Numbers
    • Copy Selection Range With Line Numbers
  3. 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');
```

Development

npm install
npm run compile

To run the extension in a VSCode Extension Development Host:

  1. Press F5 in VSCode (or use the “Run and Debug” panel).
  2. In the dev host window, open a file and execute the provided commands.

Packaging & Publishing

  1. Install the VSCode Extension Manager if you have not already:
    npm install -g @vscode/vsce
  2. Update the publisher field in package.json to match your Marketplace publisher name.
  3. Generate a package:
    vsce package
  4. Publish the extension:
    vsce publish

License

See LICENSE.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages