Get rid of Vim's highlight after searching text

In VIM, after finding text with "/" command, that text remains highlighted.

What is the command to remove that? I don't want to remove highlighting capability at all, but don't want to have all those bright text spots once I've found what I need.

Thanks.


输入这个:

:noh

You can toggle it with

:set hls!

Of course a quick and dirty alternative is to do another search for gibberish:

/asdsad

I usually bind a key to :set hls! to make this easy and use the gibberish approach when I'm in vim on some machine I don't have my profile installed on.


Completely disable search highlights

:set nohlsearch

Clear until next search

:nohlsearch

or :noh for short. This clears highlights until a new search is performed or n or N is pressed


Clear on pressing custom map

  • Clear highlights on hitting the ESC key

    nnoremap <esc> :noh<return><esc>
    
  • Clear highlights on pressing (backslash) twice

    nnoremap  :noh<return>
    
  • 链接地址: http://www.djcxy.com/p/49372.html

    上一篇: 如何摆脱Vim中的搜索亮点

    下一篇: 搜索文本后摆脱Vim的亮点