Today I Learned Telescope Spaces

I use the AstroNvim, which comes telescope-fzf-native.nvim installed by default.

FZF's fuzzy finding algorithm has an extended search mode, which supports several useful path matching modifiers.

  • ^ matches paths that start with the term
  • $ matches paths that end with the term
  • ! matches items that do not match the following term
  • (empty space) allows for multiple search terms to be included

This is really handy when your search turns up multiple items and you want to narrow it down.

For example, let's say I try searching for post in a Rails application.

![A list of all of the search results][full-results.png]

I could narrow this down to models by adding that to my query: post model.

![Just the paths that contain "model"][models.png]

I could include files only in the test directory with post ^test.

![Paths beginning with "test"][tests.png]

Or find only .erb files with post erb$.

![Paths ending in "erb"][views.png]

I can even do something like excluding view files with post !view.

![Paths that do not contain "view"][not-views.png]