This is a question to Azure Cognitive Search team. Currently we are highlighting all of the terms that are in the phrase when we try to search for exact phrase or do a proximity search.
Received an email saying that from July 15 we will be able to get updated hit highlighting mechanism.
Now it will highlight only phrases that match the full phrase query.
https://learn.microsoft.com/ru-ru/azure/search/search-pagination-page-layout
So, will highlighting change only for exact phrase search? What about proximity search? Will we highlight only the phrase? Or it will work as it is working now - highlighting all terms from the phrase everywhere they occur?
I am an engineer on the Azure Search team. Users will have improved hit highlighting behavior as notified. One of the improvements is that highlighting with phrase and proximity queries is more accurate. So, even proximity queries will see a different behavior. The new highlights for the query "quick brown"~2 will look like this -
The <b>quick</b> <em>brown</em> fox jumped over the <em>quick</em> and <em>brown</em> dog but not the quick one that was not brown.
Related
In other editors like sublime, if I search for usermodel it will match the path of models/users.ex, however in CtrlP if I do the same query it will fail. I have to remember to search the path modeluser to make the match.
Is there a way to tweak this so that usermodel or user model would match? I've read the docs and don't see a way but i'm new to it and am not sure if i'm just missing something.
AFAIK CtrlP can't do it but you can try writing your custom matcher (see an example here).
There is also Unite with similar functionality which allows to separate multiple patterns with space to narrow down the candidates. This way user model will match anything containing these two words in any order.
I ended up switching to emacs (spacemacs) with evil mode (gasp) for the improved Elixir support and i'm able to fuzzy search out of order with Helm.
Is it possible to search within vim for more than one word?
For example:
Let's say i'm inside vim and I press / in order to start a search for a certain word, is it possible to search for more than one word in the same search?
Yes, you can have several branches in a search pattern:
/foo\|bar
See :help \|.
Use the OR operator
/first\|second
If you do this often, my SearchAlternatives plugin may be useful to you.
The plugin provides mappings and commands to add and subtract alternative
branches to the current search pattern. Currently searching for "foo", but
also want to find matches for "bar"? You could type /foo\|bar<CR> or
/<C-R>/\|bar<CR>, but once you want to limit the search to whole \<words\>
(like the * command), and juggle several alternatives, adding and
dropping them as you search, this plugin is quicker than manually editing the
search command-line (which you can still do).
i. The Problem
My goal is something like the following:
I have a line of text like
Who left the dead mouse in the fridge?
and I want to highlight the first the in green, just this one occurrence. That is, I don't want to syn match ThisMagicWord "\<the\>" or anything that will overzealously highlight other thes.
There is one other requirement, which is that if the user edits the other text on the line, say to
Who on earth left the delicious dead mouse in the fridge?
the highlighting will track with the word the, so long as the user doesn't edit that one particular word.
ii. The Kludge
Now, I have a solution to this. In fact, I am proud of my solution, because it was tricky to think up. But it is not, by any stretch of the imagination, a good solution.
It turns out that the Unicode character Combining Grapheme Joiner is effectively a no-op in Vim. It produces no glyph, and takes up no width. It is the only such character that I have discovered. So what I do is, I surreptitiously edit the line in question to be
Who left the<CGJ> dead mouse in the fridge?
and then define a rule
syn match ThisMagicWord "the<CGJ>"
I will additionally trigger on BufWritePre and BufWritePost to strip the CGJs out of the file on disk.
iii. The Questions
Is there a no-op character in Vim (or a way to produce one) other than CGJ? Ideally a non-combining character, since the<CGJ> will not match a search for /the, due to the way Vim regexes handle combining characters.
Is there a better way to get at the behavior that I want?
You're right that there's currently no good way to mark static matches and keep them up-to-date when edits are done nearby. My approach would have been worse than your kludge: Include the line / column information in the match (via the \%l and \%v special atoms), and attempting to update those with a combination of marks (works for line changes) and intra-line custom diffing.
Though your use of special Unicode characters is clever, it's (as you admit) a hack. I've asked you for uses in the comments, and am still not completely satisfied / convinced. If you can come up with good, real use cases and current pain points, please direct them to the vim_dev mailing list (best with a functional draft patch attached). The functionality to keep track of such text is basically there (in the Vim internals), it's just not yet tracked and exposed to users / Vimscript. Though Vim development has been (often frustratingly) slow, with a compelling argument on your side, new functionality can and does happen.
How about using marks?
Move the cursor to the word you want, set a lowercase letter mark (e.g. mz), then add highlighting for the word like \%'zthe
this is a simple query about the searching in vim editor.
consider that i searched for a string like "str" with
/str
now after this search i wanted to search for "strcat" like
/strcat
but, the point in here is that i dont want to type entire /str again.... just wanted to add the new text to /str. that is when we made the first search we type /str and for the second search i just wanted to type cat for searching the entire /strcat.
can any of you vi guru's tell me if it is possible for us to do some search like this in vi.
thanks in advance
The / key begins a search string. up arrow recalls the previous line(s). Therefore,
/ up-arrow cat
will resume your search.
Besides up-arrow to get the previous search, you can also do /^f to be able to fully edit many previous searches. (That's / followed by Ctrl+F). Put the cursor on the previous search that you want to edit, edit it, and hit return.
Others have answered the question you asked, but on the off chance that incremental search would better suit your workflow, I thought I would mention it.
If you're only searching once and finding out that what you're searching for is not unique enough and you need to add more characters, incremental search will show you that before you press enter.
Put the following in your .vimrc to enable incremental search:
set incsearch
When in incremental search mode in Intellij IDEA, is there a way to select the rest of the word. For example, suppose I want to find the word “handleReservationGranted”. I type Ctrl-f to enter incremental search mode, and start typing the letters “han”. Now suppose I have found the beginning of “handleReservationGranted”. In my search box I have “han”, but I would now like to be able to select the rest of the word, so that the search box contains “handleReservationGranted” instead of “han”.
In Xemacs, I can type Ctrl-s, type “han”, and then type Ctrl-w. Now my search term is “handleReservationGranted”, and not “han”. So now if I press Ctrl-s, I find the next occurrence of “handleReservationGranted”.
Is there a similar feature in Intellij IDEA? The best I can do now is either to keep typing in the rest of the letters (dleReservationGranted), or exit incremental search, select the word with Ctrl-W, then enter search again with Ctrl-f.
I am using Intellij IDEA 7.0.3.
Yes, you can use autocomplete during an incremental search.
After you type "han", press CTRL-SPACE (autocomplete) and it will give you a list of potential matches in the file. Just pick "handleReservationsGranted" from the list and that will become your search term.