fzf
fzf copied to clipboard
Allow placing a ' at the end of a search term for an exact match
- Category
- [x] fzf binary
- [ ] fzf-tmux script
- [ ] Key bindings
- [ ] Completion
- [x] Vim
- [x] Neovim
- [ ] Etc.
- OS - all
- Shell - all
so that the search terms are equivalent: 'hello
and hello'
It will be useful in a use case such as this :
- I type in
hello
- there are too many search results, so I want to do an exact match. Therefore I simply type ' so the search term is
hello'
- there are still too many search results, so I type in another search term so that the search is
hello' world
currently, the use that will have to type a few more keystrokes, which is a little less intuitive
- I type in
hello
- there are too many search results, so I type
<c-a>'
- there are still too many search results, so I type in
<c-e> world
to gethello' world
In the second example the user has to do a few more keystrokes to jump back and forth between the start and end of the text field, which is a little bit unintuitive and inconvenient
Looks like this is a desired feature, see https://github.com/junegunn/fzf/issues/1305 https://github.com/junegunn/fzf/issues/1265#issuecomment-382289733. To have a command to toggle the exact
option would be really helpful.
Currently it's possible to put leading '
to enable exact
mode, but if we call fzf with --exact
option, it's impossible to toggle that back, I guess.
If using the --exact
option, putting '
at the start of the pattern will interpret it as fuzzy. So it works both ways.
@CeleritasCelery thank you for the tip.
There is a downside to this; Currently, searching for it'
does not interpret '
as magic.
@junegunn A better way is to make a single '
in the query make all the words exact matches. I don't think this would break any current workflows, as a single '
is useless in the current UI. So it's pure upside.
Some examples of what I mean:
-
hi this ' is
would become'hi 'this 'is
-
'banana is delicious '
would become'banana 'is 'delicious
-
'banana ' is delicious
would become'banana 'is 'delicious
(the same as previous one)
The meaning would be inverted if --exact
is present; A single '
would make all the words fuzzy.
@junegunn A better way is to make a single
'
in the query make all the words exact matches. I don't think this would break any current workflows, as a single'
is useless in the current UI. So it's pure upside.
@NightMachinery Just an idea:: using "wrapping" of fzf with an appropriate (expansion) tool replacing typed user input line it should be possible to implement any desired functionality like moving the trailing quotation mark ' to the start of a word or toggle the ' prefix of each word on occurrence of a single ' (surrounded by spaces) in the input. Also a patch extending fzf with an option for such "expansion" of user input should be not very hard to provide. The advantage of this approach would be that you could for example implement dynamic switching to any expansion mechanism using for example a single occurrence of some self-defined special character without the need to change the core fzf code for parsing user input.