-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Searching for value containing space by escaping space #444
Comments
Then the question is how we are going to match literal So, the options are:
|
The problem could also occur with all other characters that have specific meaning ( |
True, but the issues with those chars are limited as they are interpreted as such only when they appear at certain positions, i.e. Dynamic switching of search mode is somewhat tricky as it involves
|
I also miss a lot being able to have a space as part of the query to search for. I do some juggling around it but it's not ideal. I would be thrilled to see this implemented. The place that I miss it most is searching my .vim files. I have my vimrc split through multiple files and some code that looks like the following function! Vimrc(...)
let query = get(a:000, 0, '^')
if !len(query)
let query = '^'
endif
call fzf#vim#ag_raw(
\'--ignore ''autoload'' ' .
\'--ignore ''plugged'' '.
\query,
\fzf#vim#with_preview({'dir': '$DOTFILES/config/nvim/', 'up': '100%'}, 'up:40%', 'ctrl-g'))
endfunction
command! -nargs=? Vimrc call Vimrc(<q-args>)
map \v :Vimrc<cr> many times I wish to look for some |
Fully on board with @sudavid4. Short search terms will generate too much noise, rendering fzf's superfast fuzzy search useless. What's the point of maintaining simplicity when you're forcing the user to sift through 1000 results for |
My suggestion is that you type in
Or you can always disable extend-search mode ( |
@junegunn let me give a solid example. Assume a search for
|
So in this case you have absolutely no idea what would come after |
Having said that, there are cases when I also wish that it's possible to match spaces, that is when I search my command history (CTRL-R) because shell commands have lots of relevant spaces. For example, However, I imagine escaping all the spaces in a command can be tedious, i.e. |
I'm pretty sure in most cases you will only need 1 or 2 spaces. In your example,
But what happens when you realize you need to squeeze in a comma in your search terms? I know I would hate having to start over picking a different Speaking of metacharacters, fzf uses |
Hi,
It would (at times) be convenient to be able to be able to escape those special characters too. besides, I wouldn't want to permanently change the separator character, neither would I want to have to know ahead of time that I will need to search for a real space.
I wouldn't mind, it's not that often that I need to match a real space anyway
you have a point but with |
Also agree with @sudavid4 and @nkgm |
@junegunn thank you so much - this is working great so far. I was kind of hoping you'd also cover the One thing I've noticed messing around with it is that even though |
I felt it was not worth it and it could cause extra confusion as we currently allow users to write
No, thanks for pointing it out. I'll fix that. |
There's no need to give There's already special processing for Btw there was mention of |
If we always treat What's your opinion on the case I mentioned above? Interpreting
|
Well, it's a choice. We can always introduce more rules to support exceptional cases, or we can keep things simple by not trying to do everything. |
I don't understand, I can't seem to see this working. I've pulled and re-run ~/.fzf/install but it still matches a literal '\' when I try |
That's super cool too and was going to be my initial suggestion (I did in fact type quite a lengthy response about it)! Then I decided to rewrite my response to suggest the "precision" approach only cause I gradually realized it's not much different to what is already being done and it feels slightly more elegant (speaking strictly from the user perspective - not sure how this complicates things on the implementation side). The user already knows to watch out for a leading
But I thought @sudavid4 how about |
@nkgm I think you misinterpreted my comment. Please re-read my previous comments. My point is if we allow trailing
It's described in the man page. @sudavid4 install script will only download the prebuilt binary. You have to build fzf from source; |
Of course, how could I forget that! I did read your comments very carefully and independently reached that same conclusion last night but then took a wrong turn trying to make it as concise as possible. Here's the relevant snippet from my initial (not posted) response:
Sorry for the mixup!
Looking great as well. |
The more I think about it, the less I'm convinced that fzf should provide escaping of all meta characters for the sake of completeness. I can definitely see the appeal of |
I'm actually on the fence myself. The Wondering what other people have to say on the matter. |
I don't have a good idea. Allowing So what I think I'm going to do is to only allow escaping of spaces, use it for a while, and see if it's not too painful not to be able to match meta characters at special positions. (Meta characters are activated only when they are at special positions so we can still match |
It's probably the most sensible thing for now - get a chance to dogfood. Btw these latest refinements really inspire a lot of confidence when browsing through a codebase. Now I go straight to |
@junegunn thanks for the explanation, it works for me now, after running I suppose that finding some way to "pre-filter" by means of a real regular expression would give all the power we could possibly need while keeping the simplicity we learned to love. I believe I would consider a first term started with |
I'm updating fzf using Will that feature come later or is it already there ? Which would mean I don't know how to use it. |
@qoxxxx No official binaries have been released with the change yet. I'm planning to release a new version in a couple weeks, but you can build fzf from source now with |
fzf 0.17.0 is out with the change. |
When using fzf-history command with
<Ctrl>-R
, I sometimes search for small commands likeog ls
(a custom command I have created).However, since the "words" are very short, Typing
og
andls
won't be filtering the history sufficiently, and some non-relevant commands are showing up. I then have to manually move up and down in fzf to select the command.It would be great to be able to include a space in a search query, by for example escaping the space, eg writing :
og\ ls
which would take "og ls" as one single search query, instead of searching for
og
andls
separately`I have
--exact
in myFZF_DEFAULT_OPTS
, but I think that feature would be useful whatever your config isThe text was updated successfully, but these errors were encountered: