It can definitely be useful depending on what you want to achieve. However, I wouldn't necessarily call it "better" without a context.
To elaborate, while :let @/=""<CR> clears the search pattern, what I have (i.e.,:noh/:nohlsearch) only clears the highlighting (i.e., search pattern remains the same, just without highlighting), which is exactly what I want in most cases. This way, if I need to jump to the next occurrence of search pattern, I only need to press n which will do so, as well as start highlighting again.
I guess I'm too used to my typical workflow: while I still need my search result - I want it highlighted, but after I'm done with it - it should be gone.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
nnoremap <Leader>/ :let @/=""<CR>
Might be a better way to clear / after the search. See stackoverflow.com/a/657484 (+ comments)
I use
:command! C let @/=""
so I can simply hit:C
to clearWell, mapping is one's personal preference of course :)
It can definitely be useful depending on what you want to achieve. However, I wouldn't necessarily call it "better" without a context.
To elaborate, while
:let @/=""<CR>
clears the search pattern, what I have (i.e.,:noh
/:nohlsearch
) only clears the highlighting (i.e., search pattern remains the same, just without highlighting), which is exactly what I want in most cases. This way, if I need to jump to the next occurrence of search pattern, I only need to pressn
which will do so, as well as start highlighting again.Sure, different workflow, different approach.
I guess I'm too used to my typical workflow: while I still need my search result - I want it highlighted, but after I'm done with it - it should be gone.