Welcome to Vifm Q&A, where you can ask questions about using Vifm. Registration is optional, anonymous posts are moderated. E-mail and GitHub logins are enabled.
0 votes
in vifm by

How can I copy the name the selected files/folders to clipboard?

Thank you

1 Answer

0 votes
by

You can copy a section from sample vifmrc. There are some other variants on the Wiki.

by

Yes, I have been using this:

nnoremap <silent> \yn :!echo -n %c %i | xclip -in -selection clipboard<cr>

It copies the name of the current file/folder.

I want to copy the names of all the selected files/folders.
Would that be possible?
Thanks

by

Try

noremap <silent> \yn :!echo -n %f %i | xclip -in -selection clipboard<cr>

Note that %c was changed to %f; for more information see https://vifm.info/vimdoc.shtml#vifm-macros
nnoremap was changed to noremap so you can individually select the files, and select a range.

by

Yeah, using %f should help in this case.

nnoremap was changed to noremap so you can individually select the files, and select a range.

In other words, to make the mapping work in visual mode too.

by

It works, but makes a single line from all the selected names.

by

Oh, right, can use printf for that (head is to remove newline after the last file name):

noremap <silent> \yn :!printf '%%s\n' %f %i | head -c -1 | xclip -in -selection clipboard<cr>
by

Great, Thank you

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.
...