在Vim中,有没有办法在搜索时为所有匹配启用动态突出显示?
如果我启用incsearch并输入"/ something",它将仅突出显示第一个匹配项.如果我启用hlsearch并输入"/ something",则在按Enter键之前没有任何反应(它只突出显示上一次搜索).
在emacs中,第一个匹配将被突出显示,并且(在稍微延迟之后)屏幕上的所有其他匹配以不同颜色突出显示,在扫描一段代码中的匹配时提供几乎即时的反馈.
没有回答您的问题,但也许这篇 Wikia 帖子可以提供帮助?
引用那篇文章:
将以下代码放入 vimrc 中,或创建包含以下脚本的文件 ~/.vim/plugin/autohighlight.vim (Unix) 或 $HOME/vimfiles/plugin/autohighlight.vim (Windows)。然后重新启动 Vim。
要自动突出显示当前单词,请键入
z/。要关闭,请z/再次键入。Run Code Online (Sandbox Code Playgroud)" Highlight all instances of word under cursor, when idle. " Useful when studying strange source code. " Type z/ to toggle highlighting on/off. nnoremap z/ :if AutoHighlightToggle()<Bar>set hls<Bar>endif<CR> function! AutoHighlightToggle() let @/ = '' if exists('#auto_highlight') au! auto_highlight augroup! auto_highlight setl updatetime=4000 echo 'Highlight current word: off' return 0 else augroup auto_highlight au! au CursorHold * let @/ = '\V\<'.escape(expand('<cword>'), '\').'\>' augroup end setl updatetime=500 echo 'Highlight current word: ON' return 1 endif endfunction