Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Relative Path And Line NumberNew to Visual Studio Code? Get it now.
Relative Path And Line Number

Relative Path And Line Number

bsuooo

|
30 installs
| (0) | Free
快速复制当前文件的相对路径与行号
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Relative Path And Line Number

快速复制当前文件的相对路径与行号,格式为 relativePath:lineNumber。

选中多行时自动切换为范围格式 relativePath:startLine-endLine。

功能

  • 复制当前光标所在行的相对路径和行号到剪贴板
  • 选中多行时,复制为 file:startLine-endLine 格式
  • 复制成功后在状态栏短暂显示结果(3 秒后自动消失),不会弹窗打扰

触发方式

方式 说明
行号区域右键 在编辑器行号区域右键,选择 "Copy File Path and Line Number"
编辑器右键 在编辑器正文区域右键,选择 "Copy File Path and Line Number"
键盘快捷键 用户可在 VS Code 键盘快捷方式设置中自行绑定 extension.copyFilePathAndLineNumber 命令
命令面板 Ctrl+Shift+P / Cmd+Shift+P 搜索 "Copy File Path and Line Number"

多行选区

选中多行文本后触发复制,剪贴板内容自动变为 relativePath:startLine-endLine 格式。

  • 未选中多行时保持单行格式 relativePath:lineNumber
  • 若选区末尾恰好落在下一行行首(第 0 列),结束行号会自动修正为前一行
  • 多光标场景下仅取主选区

状态栏提示

复制成功后,编辑器底部状态栏会短暂显示:

✓ Copied: src/extension.ts:10

提示持续 3 秒后自动消失,连续复制时内容会刷新并重新计时。

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft