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.
0 votes
in vifm by
edited by

please what is the correct way to do a loop that works reliably with files containing spaces, "(" etc. this is not working as expected:

command! mycmd
        \ :execute "!!for i in %f; do echo $i; echo '===='; done"

thank you! jose

1 Answer

0 votes
by

Double percent sign like this:

command! mycmd
       \ :execute "!!for i in %%f; do echo $i; echo '===='; done"

This will postpone expansion of the macro until running :execute instead of doing it before invoking :execute.

by

thank you, it works, but not if you

  • select files
  • run :command
  • select mycmd and run it

looks like just before running it the selection is cancelled. could you please check?

by

Yeah, I confirm that selection isn't preserved. Thanks.

...