1

I've been using the FuzzyFinder plugin for Vim for a couple weeks and I'm really enjoying it so far. The one thing I do find annoying is that all those fuzzy-finding benefits are only available after Vim is already open.

Is there a way to fuzzy-find a file from the command line, rather than typing out the whole path?

Jason Swett
  • 43,526
  • 67
  • 220
  • 351
  • That seems to be more of a shell feature, try Zsh it has that behavior by default. – Jesus Ramos Jan 24 '13 at 18:45
  • Okay, perfect. I'm already using Zsh; do you know off the top of your head how to use that behavior? Googling for `zsh fuzzy matching` isn't showing anything too promising so far. – Jason Swett Jan 24 '13 at 18:51
  • For me it works just by hitting TAB, it's not the exact same behavior but it's pretty similar. For instance if I just type D*op, it expands to Desktop if I'm in my HOME folder when I hit TAB, it's been a while since I edited my zshrc though so I'm not sure. – Jesus Ramos Jan 24 '13 at 18:53
  • You might have to add `autoload -Uz compinit; compinit` to your `~/.zshrc` to get all the completion stuff working. Its fuzzy matching isn't going to be exactly like FuzzyFinder's, but there are some handy features. One example: you can do something like `vim s/p/f` and it will expand `src/projects/foo`, assuming there are no ambiguous matches. – Jim Stewart Jan 24 '13 at 18:57
  • Okay, I see the `s/p/f` thing and that's pretty cool. Not exactly the same thing, but still pretty cool. – Jason Swett Jan 24 '13 at 19:02
  • What I was hoping for was something like `vim -f somestring` that would open `path/to/file_containing_somestring.foo`. – Jason Swett Jan 24 '13 at 19:02
  • 1
    How would that scipt decide if you want `file_containing_somestring.foo` and not `other_file_containing_somestring.foo`? How would it show that there are other matches? How would it show you those other matches? – romainl Jan 24 '13 at 20:26
  • I was guessing that maybe it would do those things by opening Vim or something. – Jason Swett Jan 25 '13 at 15:07

2 Answers2

1

You can start Vim with FuzzyFinder pre-populated:

vim -c ":FufFile somefilepattern"

Then you only need to select the file from the control.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • This seems very close to what I want, thanks. If I type `vim -c ":FufFile **/somefilepattern"`, it works, but I have to hit the right arrow key until I get to the end of `somefilepattern` and then start typing in order for FuzzyFinder to kick in. Am I missing something? – Jason Swett Jan 25 '13 at 14:29
  • I'll select your answer even though it's not 100% working for me. Whatever my particular issue is, your answer is exactly what I was looking for. Thanks. – Jason Swett Jan 25 '13 at 15:08
1

You can do it with zsh, check this demo

Thiago Padilha
  • 4,590
  • 5
  • 44
  • 69