Open yous opened 7 years ago
Thanks, I can reproduce. Vim stops processing the rest of the sequence on error (see :help map-error
), so that's why in that case slash fails to register the autocmd for clearing the search highlight.
gd
also has the same issue. If you press gd
on the first occurrence of a keyword, it will fail and highlighting will remain. Unfortunately, I'm not aware of a solution to the problem.
Possibly related (?):
Using :substitute
Substitute and re-insert substituted:
:%s/something/idontknow/g
Substitute with 'confirm' flag (c
):
:%s/something/idontknow/gc
n
(no)The first scenario is quite rare, but for those who use the c
flag a lot, it's a bigger issue.
Edit: Also using a line range (e.g. :1,10s///g
will highlight matches outside of the range and won't clear
Anyway, are the substitute issues similarly not possible to solve? I'm interested in finding solutions.
Recently I experienced an issue multiple times. When I search something and there is no match in the current buffer, then search highlight is not cleared even if I move the cursor.
This is the minimal vimrc to reproduce:
Open Vim and search anything, for example,
/test
. Then we'll seeE486: Pattern not found: test
error. Just insert that text,test
to the buffer. Then it'll be immediately highlighted. If I turn off the search highlight, I need to type:noh
or search that term again and move the cursor.This issue is clearer when there are multiple windows open. One having no match, and the other having one match or more. If the current buffer doesn't have a match, then the search highlight of the other is not cleared when I move the cursor.