7

Is there a quick way to copy the full path of current buffer to system clip board or some register? :put=expand('%:p') then use other copy commands(like dd) works but the typing is a little long.

6

You can assign to the clipboard with the special + register:

:let @+ = expand('%:p')

If you want to make this easier, you could create a command, so you only have to type :CopyBuffer:

:command! CopyBuffer let @+ = expand('%:p')

and/or map it to a key:

:nnoremap <Leader>c :let @+=expand('%:p')<CR>

The post "How can I copy text to the system clipboard from Vim?" has much more information on how to interface with the system's clipboard.

:put=expand('%:p') works but the typing is a little long.

This doesn't copy the path of the buffer to the clipboard, but inserts it in the buffer...?

  • Thanks. I meant put into buffer then copy to clipboard or registers via other command. – Thomson Jun 24 '15 at 17:19
  • @Thomson So you want to do 2 operations in 1 go? Put the filen name in the buffer and copy it to the operating system's clipboard? – Martin Tournoij Jun 24 '15 at 19:55
  • I just want to copy the file name of the buffer to clipboard, the previous 2 operations are an crappy workaround. – Thomson Jun 24 '15 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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