سؤال

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?

هل كانت مفيدة؟

المحلول

If you are trying to yank c:\foo\bar\file.txt:94 when you are on line 94 of c:\foo\bar\file.txt you can use the following statement to set the + register to
<file_path>:<line_number>

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

expand("%") - is the current file name
line(".") - is the current line number

An example mapping is

nnoremap <leader>y :let @+=expand("%") . ':' . line(".")<CR>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top