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?

Nathan Long
  • 403
  • 1
  • 3
  • 7

1 Answers1

0

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>")

Nathan Long
  • 403
  • 1
  • 3
  • 7