问题
I have set incsearch set in my .vimrc and it highlights EVERY matched pattern only when tapping enter. But is there any way to highlight all the matches while typing in the search?
回答1:
That's what :set incsearch is about: showing the matches while typing the pattern:
Ensure that the IncSearch highlight group actually has distinctive visual features; it may have been cleared:
:hi IncSearch
Only the next match is highlighted here; this is to enable the features mentioned at :help 'incsearch':
CTRL-L can be used to add one character from after the current match to the command line. If 'ignorecase' and 'smartcase' are set and the command line has no uppercase characters, the added character is converted to lowercase.
CTRL-R CTRL-W can be used to add the word at the end of the current match, excluding the characters that were already typed.
If you want all matches highlighted, you have to either modify Vim's source code (and eventually post a patch), or re-implement search (using getchar() and matchad()) entirely in Vimscript. Both are not trivial, so I'd recommend to stick with the status quo.
来源:https://stackoverflow.com/questions/20899816/highlight-every-matched-pattern-while-searching-in-vim