问题描述
我知道可以阻止 Vim 在任何搜索中高亮显示,但有没有办法让它在常规搜索中高亮显示,而不是在替换时高亮显示?
I know it's possible to stop Vim from highlighting on any search, but is there a way to make it highlight on regular searches but not, for instance, substitutions?
我通常会突出显示一段文本,然后执行以下操作:
I will often highlight a block of text then do something like:
:s/^/#/
注释掉整个块.但是后来我的屏幕左侧出现了一个丑陋的黄色条,我每次都必须:noh
来清除它.
to comment out the whole block. But then I have an ugly yellow bar running up and down the left side of my screen and I have to :noh
every time to clear it.
我希望突出显示保留在常规/搜索中.这可能吗?
I want highlighting to remain on regular /searches. Is this possible?
推荐答案
这并没有完全回答你的问题,但对我有同样的问题有帮助:我添加了这个命令来轻松地在搜索或搜索后取消突出显示-和-替换
This doesn't answer your question fully but for me having the same problem it helped: I added this command to easily deactivate the highlighting after a search or a search-and-replace
nnoremap <esc> :noh<return><esc>
(来自 Vim 清除上次搜索突出显示)
这篇关于突出显示 Vim 中的搜索而不是替换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!