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 /
contains 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?
:h function-search-undo
– Christian Brabandt Jun 12 '16 at 19:09@/
will highlight matches. – Antony Jun 14 '16 at 10:12vim -u NONE
. It works like that. – Antony Jun 14 '16 at 10:23vim -u NONE
. Doesn't if I start withvim -Nu NONE
, even if I then:set compatible
. Bug? Vim 7.4.778 btw. – Antony Jun 14 '16 at 10:30