像在Notepad++中一样,如何在GVim中突出显示所选单词的所有匹配项?
发布于 2010-08-08 00:38:37
在正常模式下:
:set hlsearch然后在正常模式下使用命令/搜索模式,或者在插入模式下使用<Ctrl>o后跟/搜索模式。正常模式下的*将搜索光标下的下一个单词。如果设置了hlsearch选项,则会突出显示所有这些选项。#将搜索该单词的上一个匹配项。
要删除上一次搜索的突出显示,请执行以下操作:
:nohlsearch您可能希望将:nohlsearch<CR>映射到某个方便的键。
发布于 2010-08-08 00:36:43
*键将突出显示光标下出现的所有单词。
发布于 2014-09-29 02:56:09
我知道这是一个非常古老的问题,但是如果有人对这个特性感兴趣,可以查看这个代码http://vim.wikia.com/wiki/Auto_highlight_current_word_when_idle
" 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
endfunctionhttps://stackoverflow.com/questions/3431184
复制相似问题