I am trying to highlight a word in the current buffer dynamically like so:
function! Highlight() let @/ = 'word' set hlsearch endfunction
When I run this function, the register
word as desired but the word
word is not highlighted.
This surprises me because if I remove the
set hlsearch part and after the function runs, I call it manually, it highlight correctly the word.
What can I do to have the correct behavior?