0

How can I copy the current file name and line number to the system clipboard, formatted like this:

relative/path/to/file:123

And how can I map this to a leader key command?

1 Answer 1

1

The necessary command is :let @+ = expand('%') . ':' . line(".")

This can be mapped to a leader key command like this:

:nmap <Leader>l <Esc>:let @+ = expand('%') . ':' . line(".")<CR>

The equivalent in Lua for NeoVim is:

set("n", "<Leader>l", ":let @+ = expand('%') . ':' . line('.')<cr>")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.