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

Dear developer(s),

Thank you for creating and maintaining this wonderful piece of software!

Now for an experiment that I was performing. This is a file called printSelectionToFile.sh:

echo "$@" > ~/Documents/selectedFiles.txt

to simply print the received inputs to a file. In .vifmrc I have bound the script to a file 'association':

filextype *.avi,*.mp4,*.wmv,*.dat,*.3gp,*.ogv,*.mkv,*.mpg,*.mpeg,*.vob,
         \ printSelectionToFile.sh %f,

and also to a key:

nnoremap <f2>q :! printSelectionToFile.sh %f<CR>

Consider the situation:

  • video1.mp4 = selected,
  • video2.mp4 = selected,
  • video3.mp4 = under the cursor but not selected

Now when I press F2+q I can check from the selectedFiles.txt file that the script printSelectionToFile.sh received as inputs video1.mp4 and video2.mp4 as expected. However, if I press the launch button (l, right-arrow, etc) it can be verified that the script now received video3.mp4 as input. It seems like the macro %f in the filextype association is replaced by %c. Is this normal? From the explanation in the default .vifmrc I would guess that also in this case the macro %f should expand to the selection and not to the file under the cursor ...

In case it matters: My vifm version is v0.10.1 obtained from github and compiled from source and running from ubuntu 18.04.

Thank you and wkr,
Happy vifm user

1 Answer

0 votes


printSelectionToFile.sh %f

An easier way is to do

echo  %f %S

and then check what appears on the statusbar.

It seems like the macro %f in the filextype association is replaced by %c. Is this normal?

That's how it behaves sometimes, but I don't think it's documented anywhere.

If there is a selection when l key is pressed, it's ignored unless file under the cursor is part of that selection.



I just checked again and indeed if de item under the cursor is part of the selection the entire selection is expanded at %f for a filextype application! The delta in %f macro behavior between filextype and key mappings must have been what has confused me ...

Thanks very much for the info! ... I have just learned something new again ;)

With kind regards,

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.

Support Ukraine