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.
+1 vote
in vifm by
edited by

I want to use this fuzzy file finder to search for and select a file in my current pane. Running the program brings up an interactive screen where you type in a part of a file name, and when you hit enter it prints the absolute path of the file that most closely matches your search to stdout. Adding the following command to my vifmrc file does basically what I want.

command! fzf vifm --select $(fzf)

The problem is that this opens a new vifm instance within my current one, so to quit, I have to hit :q multiple times to close out all the nested instances. Is there a better way to do this?

2 Answers

0 votes
by
edited by
 
Best answer

There is no direct way, but navigation from custom view can be used here like this:

command! fzf :execute '!fzf 2>&0 %%U' | normal! gf

It basically creates a view consisting of a single file and performs navigation to it (gf). % is doubled because it's inside user-defined command, which also performs macro expansion. stdin -> stderr redirection is needed because fzf doesn't look for terminal in stdin and vifm redirects stderr to capture errors.

UPD: Some issues with the command above have been reported here. Development version after 0.8.2 (and so the next release) has %IU macro, which should be used to prevent possible issues with interface after calling fzf:

command! fzf :execute '!fzf 2>&0 %%IU' | normal! gf
by

Thank you very much! This helps a lot, and I appreciate the quick response.

+1 vote
by
edited by

If you have --remote options enabled

command! fzf vifm --remote --select $(fzf)

will do it right, as long as your current vifm instance is the only one running

--remote option may not be available though, depending on the vifm installation you used.
If that is your case, you still can get it by building vifm yourself, that's easy enough,
here's the link for your conveniences https://wiki.vifm.info/index.php?title=Obtaining_Vifm#From_sources

...