VIM: FuzzyFinder usage, tips, gotchas - how can one make use of this plugin?

Viewed 14743

http://www.vim.org/scripts/script.php?script_id=1984

You can launch FuzzyFinder by following commands:

     Command           Mode ~
    |:FufBuffer|     - Buffer mode (|fuf-buffer-mode|)
    |:FufFile|       - File mode (|fuf-file-mode|)
    |:FufDir|        - Directory mode (|fuf-dir-mode|)
    |:FufMruFile|    - MRU-File mode (|fuf-mrufile-mode|)
    |:FufMruCmd|     - MRU-Command mode (|fuf-mrucmd-mode|)
    |:FufBookmark|   - Bookmark mode (|fuf-bookmark-mode|)
    |:FufTag|        - Tag mode (|fuf-tag-mode|)
    |:FufTaggedFile| - Tagged-File mode (|fuf-taggedfile-mode|)
    |:FufJumpList|   - Jump-List mode (|fuf-jumplist-mode|)
    |:FufChangeList| - Change-List mode (|fuf-changelist-mode|)
    |:FufQuickfix|   - Quickfix mode (|fuf-quickfix-mode|)
    |:FufLine|       - Line mode (|fuf-line-mode|)
    |:FufHelp|       - Help mode (|fuf-help-mode|)

So I just recently found out about FuzzyFinder. For anyone who's used this for quite awhile, can you demonstrate how you actually use these commands in combination, any mappings you make, any gotchas that one should know while using this?

7 Answers

FuzzyFinder on itself is pretty useless to me. I use it in combination with FuzzyFinder-TextMate and a Ruby library that traverses all files and subdirectories to find a file, much like the Cmd+T option for TextMate on a Mac. You can see it in action here.

Unfortunately, it takes some effort to get it to work since the original author stopped maintaining the script. There are still some people regularly posting updates to github though. You will need two scripts, fuzzyfinder_textmate.vim and fuzzy_file_finder.rb.

The latest versions work without a problem in combination with Vim FuzzyFinder 2.22.3. Your Vim has to be compiled with Ruby support otherwise it will not work. The blog of the original author contains more information on how to use it properly. Alternatively, have a look at my Vim setup to see how it can be used. The setup defines two keymappings ,s and ,e to fuzzy find a file and open it in a new window or the current window respectively:

function IdeFindTextMate()
  let g:FuzzyFinderOptions.Base.key_open = '<CR>'
  let g:FuzzyFinderOptions.Base.key_open_split = '<C-j>'
  exe "FuzzyFinderTextMate"
endfunction

function IdeSplitFindTextMate()
  let g:FuzzyFinderOptions.Base.key_open = '<C-j>'
  let g:FuzzyFinderOptions.Base.key_open_split = '<CR>'
  exe "FuzzyFinderTextMate"
endfunction

let mapleader = ","
map <silent> <leader>e :call IdeFindTextMate()<CR>
map <silent> <leader>s :call IdeSplitFindTextMate()<CR>

Update:

Right now I use the excellent Command-T plugin instead of FuzzyFinder. Have a look at this superuser answer of mine for the reasons why.

OK, after using vim fuf for 12+ years, I finally find the answer: "how to exclude an folder when search files between node_module folder" : (answer copied from @Jonathan )

" Truth be told, I don't remember what these do, but I must have
" found them necessary back when I installed fuzzyfinder years ago
let s:slash = '[/\\]'
let s:startname = '(^|'.s:slash.')'
let s:endname = '($|'.s:slash.')'

" directories and extensions to ignore when listing files
" these contain a lot of Python-isms, yours will probably vary
let s:extension = '\.bak|\.dll|\.exe|\.o|\.pyc|\.pyo|\.swp|\.swo'
let s:dirname = 'build|deploy|dist|vms|\.bzr|\.git|\.hg|\.svn|.+\.egg-info'
let g:fuf_file_exclude = '\v'.'('.s:startname.'('.s:dirname.')'.s:endname.')|(('.s:extension.')$)'
let g:fuf_dir_exclude = '\v'.s:startname.'('.s:dirname.')'.s:endname

" limit number of displayed matches
" (makes response instant even on huge source trees)
let g:fuf_enumeratingLimit = 60
Related