I'm trying to create a script for performing fuzzy search inside a buffer. The main idea is to take some input, and insert .\{-}
between every pair of characters, e.g. foo
becomes f.\{-}o.\{-}o
.
This works fairly well, but comes up with a lot of non-ideal matches. I think a fuzzy search should yield the shortest matches first. Consider the following example:
public void put()
Doing a fuzzy search for put
(so, p.\{-}u.\{-}t
) will match the entire string public void put
, but the shorter put
within that match would be more useful.
The non-greedy operator is good at finding matches that end earlier, but I need something that can, at the same time, prefer matches that start later. Conceptually, it should be non-greedy in both directions. Is this possible?