Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Copy Selection with Line NumbersNew to Visual Studio Code? Get it now.
Copy Selection with Line Numbers

Copy Selection with Line Numbers

suzukenz

|
1 install
| (0) | Free
VSCode extension to copy code with line numbers
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Copy Selection with Line Numbers

A Visual Studio Code extension that allows you to copy selected code with line numbers.

Features

This extension adds a command to copy your selected code with line numbers prepended to each line. This is particularly useful when:

  • Sharing code snippets in documentation
  • Discussing specific lines in code reviews
  • Creating educational materials
  • Referencing code in bug reports

Example

When you select this code in src/example.ts:

function greet(name: string) {
  console.log(`Hello, ${name}!`);
}

And run the "Copy Selection with Line Numbers" command, it copies:

// src/example.ts
1: function greet(name: string) {
2:   console.log(`Hello, ${name}!`);
3: }

The first line contains the file path (relative to workspace root for saved files, or just the filename for untitled files), followed by the selected code with line numbers.

Usage

  1. Select the code you want to copy in the editor
  2. Open the Command Palette (Cmd+Shift+P on macOS or Ctrl+Shift+P on Windows/Linux)
  3. Type "Copy Selection with Line Numbers" and select the command
  4. The selected code with line numbers is now copied to your clipboard
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft