0

I am trying to learn vim, and am trying to do so without any plugins. Tried following a few accounts on how to set up a fuzzy search, but I am a little stuck.

What I have in my vimrc as it concerns searching files, and how I understand it to be working is below:

" search down into subfolders/provides tab-completion for all file-related tasks
set path+=**

" display all matching files when we tab complete
set wildmenu

What is happening:

  1. I type :find filena at the bottom of the editor
  2. Hit tab to see some autocomplete action
  3. What shows up instead at the bottom is something like this: :find filena... and the editor seems to be in a frozen state. I hit Ctrl-c and am able to get out of it.

If I type in the complete filename and hit <enter> it works no problem, finding the file immediately. But the autocomplete is not functioning as I would expect. Any insight would be greatly appreciated!

Some more info if it might be helpful:

  1. When I <enter> :set path, this is returned: path=.,/usr/include,,,** which should be fine from what I have read.
  2. Other post looking to implement a fuzzy search without plugins. Have tried a couple of other ways, but with the same behavior: Opening files in Vim using Fuzzy Search
  3. The path on the machine I am working on (a bit of mess I admit, but not sure if it might be the culprit): /Users/NJJJ/bin:/Users/NJJJ/.rbenv/shims:/Applications/Postgres.app/Contents/Versions/latest/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Postgres.app/Contents/Versions/latest/bin

Thanks in advance!

Noejoa
  • 1
  • From what I saw, vim searches from your current position, so if you're at `/` for example, it will fuzzy-search on your whole system... So it really depends where you're searching from – Zorzi Apr 14 '20 at 11:20
  • 1
    Yes, absolutely right, thanks! I forgot to check where I was launching vim from, and that was costly. Fixed when that was addressed. That said, will probably use a plugin going forward given the interference Ben Knoble mentions below. – Noejoa Apr 14 '20 at 17:41

1 Answers1

1

Do not set path+=**.

There’s a whole bunch of reasons, but it boils down to

  1. You hurt the value of commands like gf (here’s a list with more)
  2. You can cause very slow complete for :find and friends, as you’ve noticed.

This is because is performing a recursive directory walk of the entire system (or at least the system under your current directory). This is heavier than it needs to be.

D. Ben Knoble
  • 4,273
  • 1
  • 20
  • 38
  • Thanks for response! The link you posted seems to suggest going with a plugin for searches to avoid the interference you mentioned. Had no idea the interference would be an issue, but makes sense. – Noejoa Apr 14 '20 at 17:36