8

I would like to yank -

  • A full path to the file, e.g. c:\foo\bar\file.txt:94 with its line no

I would also like to paste it to my system clipboard so i will use '+' register for this.

can you suggest me possible way to do this?

4

1 回答 1

14

c:\foo\bar\file.txt:94如果您在第 94 行时尝试拉动,c:\foo\bar\file.txt可以使用以下语句将+寄存器设置为
<file_path>:<line_number>

:let @+=expand("%") . ':' . line(".")

expand("%")- 是当前文件名
line(".")- 是当前行号

一个示例映射是

nnoremap <leader>y :let @+=expand("%") . ':' . line(".")<CR>
于 2013-07-06T00:00:02.957 回答