:noh is executed automatically
Well, that's kind of prohibited.
The last used search pattern and the redo command "." will not be changed by the function. This also implies that the effect of |:nohlsearch| is undone when the function returns.
Note that internally all autocommands are functions, so
:noh inside an autocommand won't have any effect either.
Therefore, you are more or less confined to
feedkeys() like that
augroup autonoh | au!
autocmd CursorHold * if v:hlsearch | call feedkeys(":noh\<CR>", 'n') | endif
(Don't try to make use of
timer_start() even if you have it in Vim7, as for this case you'll certainly also need
SafeState, but it's available in Vim 8.1+ only).
Still, that does not feel good to me, so I believe that a mapping (
nnoremap <C-L> :noh<CR><C-L>, or whatever) should be preferred.