VS Code extension that ports the editor copy behaviors from the IntelliJ plugin:
- Copy selected code with line numbers and full path
- Copy selected code with line numbers and relative path
- Copy only file path and selected line range
- Copy selected code with an expanded full-path line range header
- Copy the touched full lines with
File: ...:start-end 行header - Default shortcut aligned with the original plugin:
Ctrl+Shift+C/Cmd+Shift+C
Menu
In the editor context menu, the commands are grouped under a top-level submenu:
Copy Extra
Commands
Copy Full Path and Line Range OnlyCopy Relative Path Line Range OnlyCopy Full Path Line Range Scope SelectedCopy Full Path Line Range SelectedCopy Full Path Line Numbers SelectedCopy Relative Path Line Range SelectedCopy Relative Path Line Numbers SelectedCopy Full Path Line RangeCopy Full Path Line NumbersCopy Relative Path Line RangeCopy Relative Path Line Numbers
Copy Full Path Line Range Scope Selected copies the selected code text only, while the header line range expands around the selection. The before/after line counts are configurable and default to 5 lines before and 5 lines after the selection.
Settings
Configure under VS Code Settings:
copyExtra.windowsCopyPathFormat: Windows-only full path output format. macOS, Linux, and Unix use the default VS Code path format.copyExtra.pathPrefix: Prefix used for copied folders in Explorer. Default:Path:.copyExtra.filePrefix: Prefix used before copied file paths. Default:File:.copyExtra.fileSuffix: Suffix used after editor line ranges. Default:行.copyExtra.scopeSelectedBeforeLineCount: Number of lines before the selection included in theCopy Full Path Line Range Scope Selectedheader. Default:5.copyExtra.scopeSelectedAfterLineCount: Number of lines after the selection included in theCopy Full Path Line Range Scope Selectedheader. Default:5.
Shortcut
Ctrl+Shift+Con Windows/LinuxCmd+Shift+Con macOS
This shortcut runs Copy Full Path Line Range Scope Selected.
Install
Install the packaged extension from:
copy-extra-by-qinghao-plus-0.0.9.vsix
In VS Code:
- Open Extensions
- Click
... - Select
Install from VSIX... - Choose the
.vsixfile - Reload VS Code
Command line:
code --install-extension /mnt/d/abc/CopyWithLineNumbersExtraVSCode/copy-extra-by-qinghao-plus-0.0.9.vsix
Development
npm install
npm run build
Press F5 in VS Code to launch an Extension Development Host.