1

I'm on Win 10 and want to get rid of the Windows-Explorer and use mostly my keyboard with vifm. But I have problems assigning a file extension to a specific app. Everything I want to open is opened with the built-in vim, instead of my external Apps.

Here is an Example from my config:

" Pdf
filextype *.pdf
    \ {View in AR}
    \ C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe %f

I have two Questions right now: - Is there really no 'Open-With'-function in vifm? Can't believe.... - How do I correctly assign the file types in my win-environment?

Thanks 4 your support!!

Matumba77
  • 21
  • 2

2 Answers2

3

Late answer, but Xaizek's solution contains a few inaccuracies and isn't complete, since it is possible to get the open with dialogue if you're willing to jump through a tiny hoop:

To open pdf files by default with AcroRd32 you should add the following lines to your vifmrc:

filextype *.pdf
    \ {View in AR}
    \ "C:/Program Files (x86)/Adobe/Acrobat Reader DC/Reader/AcroRd32.exe" %"f &,

Note the forward slashes. Without these the command won't work. It's also generally a good idea to add &, at the end of any filextype line. This will allow acrord32 to open in the background and won't interrupt your vifm session; otherwise you'll have to close the pdf to continue using vifm.

On the second point, 'start' requires empty double quotes after it to work here:

filextype *.pdf
    \ {View in default application}
    \ start "" %"c &,

An alternative is to use explorer in place of start "". It's worth noting that this will only allow you to open one file a time instead of batch opening every selected pdf.

You can also open any file in a specific program via the shell, e.g. :!gvim %"c & will open the currently selected file in gvim. You may also replace %"c with any file name you want in the current directory.

Finally, you can get an open with dialogue for any selected file via the following method:

Create the file, ow.cmd, in your vifm directory (or any other location in your path) with the following contents:

Rundll32.exe shell32.dll,OpenAs_RunDLL %~1

Then add the following to your vifmrc:

" Create 'open with' dialogue box for selected file
nnoremap go :!ow.cmd %"c:p &<cr>

Now if you hit go within vifm it will bring up an 'open with' dialogue for the currently selected file. The external script is sadly necessary in order to remove the quotes from the file name that %"c:p tacks on.

Toby Hawkins
  • 247
  • 3
  • 11
1

There are two things that you need to fix with the command:

  1. Escape spaces in path by enclosing it in quotes (vifm checks if programs are present and thus needs to be able to extract executable path from command-line).
  2. Use Windows-friendly macro %"f instead of %f.

This will give you:

" Pdf
filextype *.pdf
    \ {View in AR}
    \ "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" %"f

Which should work.

Is there really no 'Open-With'-function in vifm?

Depends on what you mean. There is :file command, which will display list of registered file associations. If you just want to go with those registered in Windows, then use catch-all association filetype * start. If you're talking about "Open with" menu like in Explorer, then no, such querying of registered associations is not performed.

xaizek
  • 5,098
  • 1
  • 34
  • 60