Welcome to Vifm Q&A, where you can ask questions about Vifm usage. Registration is optional, anonymous posts are moderated. GitHub or Google logins are enabled.

Windows 10: official help's 'yank path to current file to Windows clipboard' suggestion does not work correctly

0 votes
asked Oct 18 in vifm by George

Hello,

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:

"myfile.txt"

including the quotation marks. Ideally, I think the clipboard should contain:

 C:/temp/myfile.txt

How we would go about achieving this? Any help would be appreciated.

Best regards.

1 Answer

0 votes
answered Oct 18 by xaizek

Hello,

try this (added :p):

nnoremap yf :!echo %"c:p:gs!\!/! %i | clip<cr>
commented Oct 18 by George

Thank you very much, that did the job.

One more thing: any chance the quotation marks can be removed as well? My clipboard contains:

"C:/temp/myfile.txt"
commented Oct 18 by xaizek

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.

If you would like to make a bug report or feature request consider using GitHub, SourceForge or e-mail. Posting such things here is acceptable, but this is not a perfect place for them.
...