I am using the following two items in my mapping:

set hlsearch
nnoremap <esc><esc> :noh<return>

When I search I normally like to see highlighting, and then once I get to 'where I want', I disable the highlighting. However, it seems whenever I run a function, I lose the :noh and my search results keep re-highlighting. Is this a common issue, and if so, how is it dealt with? For a function in my vimrc would the following work?

func MyFunction()
    call execute('noh')
    " rest of function...
  • I believe such question was asked 1000 times. Just read :h noh carefully. It's all written in help. – Matt Jun 13 '20 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.