Difference between revisions of "How to integrate fzf for fuzzy finding"

From Vifm Wiki
Jump to navigation Jump to search
m (Corrected lang spelling)
Line 19: Line 19:
  
 
In both examples <code>fzf</code> will pop up on the bottom and allow us to filter the output of the feeder command. Once our selection is made, <code>fzf</code> will close and <code>vifm</code> will advance the active pane to the directory of the selected file with the cursor highlighting it.
 
In both examples <code>fzf</code> will pop up on the bottom and allow us to filter the output of the feeder command. Once our selection is made, <code>fzf</code> will close and <code>vifm</code> will advance the active pane to the directory of the selected file with the cursor highlighting it.
 
  
 
=== Mappings ===
 
=== Mappings ===
Line 25: Line 24:
 
We can then add the following mappings to run these commands from normal mode:
 
We can then add the following mappings to run these commands from normal mode:
  
<source land="vim">
+
<source lang="vim">
 
nnoremap <c-g> :FZFlocate<cr>
 
nnoremap <c-g> :FZFlocate<cr>
 
nnoremap <c-f> :FZFfind<cr>
 
nnoremap <c-f> :FZFfind<cr>

Revision as of 16:34, 10 December 2018

vifm Already has powerful search features such as :grep and :locate however it is possible to further expand its capabilities with fun and powerful programs such as fzf "a general-purpose command-line fuzzy finder."

Prerequisites

You need to have fzf installed. This method creates pipelines using the find and locate commands which are present in most Linux distributions.

Considerations

fzf is a powerful and quick interactive filter in addition to working as a file searching utility by default. This method focuses on piping the output from locate $HOME for quick traversal though the user's $HOME directory and the output from find for recursive traversal.

Examples

Commands

We can add the following two commands to ~/.config/vifmrc:

command! FZFlocate :execute 'goto "'.system('locate $HOME | fzf --height 10 2>/dev/tty ').'"%IU' | redraw
command! FZFfind :execute 'goto "'.system('find | fzf --height 10 2>/dev/tty ').'"%IU' | redraw

In both examples fzf will pop up on the bottom and allow us to filter the output of the feeder command. Once our selection is made, fzf will close and vifm will advance the active pane to the directory of the selected file with the cursor highlighting it.

Mappings

We can then add the following mappings to run these commands from normal mode:

nnoremap <c-g> :FZFlocate<cr>
nnoremap <c-f> :FZFfind<cr>

In this example I have chosen CTRL-g and CTRL-f.