In this page we see the following:
" yank path to current file to Windows clipboard with forward slashes
nnoremap yf :!echo %"c:gs!\!/! %i | clip<cr>
However, with this in my configuration file, if I navigate to a file, say "C:/temp/myfile.txt", and press "yf", my clipboard will contain:
including the quotation marks. Ideally, I think the clipboard should contain:
How we would go about achieving this? Any help would be appreciated.
try this (added :p):
nnoremap yf :!echo %"c:p:gs!\!/! %i | clip<cr>
Thank you very much, that did the job.
One more thing: any chance the quotation marks can be removed as well? My clipboard contains:
You can try dropping " to get
nnoremap yf :!echo %c:p:gs!\!/! %i | clip<cr>
but I'm not sure how well it would work with paths containing spaces. Those quotation marks are there to do the escaping, but echo doesn't handle its arguments properly.