如何在 VIM 中突出显示所有出现的选定单词?
问题描述:
如何在 GVim 中突出显示所有出现的选定单词,就像在 Notepad++ 中一样?
How can I highlight all occurrence of a selected word in GVim, like in Notepad++?
答
普通模式:
:set hlsearch
然后在普通模式下使用命令 /
搜索模式,或者在插入模式下使用
后跟 /
搜索模式.*
在普通模式下将搜索光标下出现的下一个单词.如果设置了 hlsearch
选项将突出显示所有这些.#
将搜索之前出现的单词.
Then search for a pattern with the command /
in Normal mode, or <Ctrl>o
followed by /
in Insert mode. *
in Normal mode will search for the next occurrence of the word under the cursor. The hlsearch
option will highlight all of them if set. #
will search for the previous occurrence of the word.
要删除上一次搜索的突出显示:
To remove the highlight of the previous search:
:nohlsearch
您可能希望将 :nohlsearch<CR>
映射到某个方便的键.
You might wish to map :nohlsearch<CR>
to some convenient key.