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.

the correct way to loop selected files in execute cmd

0 votes
asked Aug 24 in vifm by jose1711
edited Aug 25 by xaizek

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
answered Aug 25 by xaizek

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.

commented Aug 25 by jose1711

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?

commented Aug 25 by xaizek

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

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