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.
-
To any register: stackoverflow.com/questions/916875/…– Ciro Santilli OurBigBook.comOct 20, 2015 at 8:56
1 Answer
You can assign to the clipboard with the special +
register:
:let @+ = expand('%:p')
The :p
makes it an absolute path; drop it if you want the relative path.
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.– ThomsonJun 24, 2015 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? Jun 24, 2015 at 19:55
-
I just want to copy the file name of the buffer to clipboard, the previous 2 operations are an crappy workaround.– ThomsonJun 24, 2015 at 22:22