Highlight every matched pattern while searching in Vim [duplicate]

时间秒杀一切 提交于 2019-12-21 09:17:06

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!