How to get rid of search highlight in Vim

前端 未结 7 1029
误落风尘
误落风尘 2020-12-13 03:25

I have :set hlsearch as default value.

When I search for something, search terms get highlighted. However many times I want to get rid of the highlight,

相关标签:
7条回答
  • 2020-12-13 03:54

    Try this:

    set hlsearch!
    nnoremap <F12> :set hlsearch!<CR>
    

    and hit F12 to clear when desired. Use :noh in command mode to clear.

    0 讨论(0)
  • 2020-12-13 04:00
    :noremap <silent> <c-l> :nohls<cr><c-l>
    

    This would redraw the screen and clear any search terms with Control-L, handy :) easier than reaching up to the F keys.

    0 讨论(0)
  • 2020-12-13 04:03

    This might suit your needs:

    nnoremap <esc> :noh<return><esc>
    

    With a little tinkering you can make it work in insert mode.

    0 讨论(0)
  • 2020-12-13 04:05

    Try the :noh command.

    vi/vim notes

    0 讨论(0)
  • 2020-12-13 04:09

    I have the following in my .vimrc:

    map <silent> <C-N> :let @/=""<CR>
    
    0 讨论(0)
  • 2020-12-13 04:10

    you could search for something not in the text file. Nothing will be highlighted in this case. (e.g. /349i5u9sgh)

    0 讨论(0)
提交回复
热议问题