如何在 VIM 中突出显示所有出现的选定单词? [英] How to highlight all occurrences of a selected word in VIM?

查看:28
本文介绍了如何在 VIM 中突出显示所有出现的选定单词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 GVim 中突出显示所有出现的选定单词,就像在 Notepad++ 中一样?

How can I highlight all occurrence of a selected word in GVim, like in Notepad++?

推荐答案

普通模式:

:set hlsearch

然后在普通模式下使用命令 / 搜索模式,或者在插入模式下使用 o 后跟 / 搜索模式.* 在普通模式下将搜索光标下出现的下一个单词.如果设置了 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.

这篇关于如何在 VIM 中突出显示所有出现的选定单词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆