I am using
nnoremap <esc> :noh<return><esc>
to remove the highlighting after a search with hlsearch on.
Pressing <esc>, this shows :noh in the command line. I would like to turn this off (preferably without any side effects).
I am using
nnoremap <esc> :noh<return><esc>
to remove the highlighting after a search with hlsearch on.
Pressing <esc>, this shows :noh in the command line. I would like to turn this off (preferably without any side effects).
As @VanLaser mentions in a comment, you can do this by adding <silent> to your map command:
nnoremap <silent> <esc> :noh<return><esc>
:help :map-silent explains:
To define a mapping which will not be echoed on the command line, add "
<silent>" as the first argument. Example::map <silent> ,h /Header<CR>The search string will not be echoed when using this mapping. Messages from the executed command are still given though. To shut them up too, add a ":silent" in the executed command:
:map <silent> ,h :exe ":silent normal /Header\r"<CR>Prompts will still be given, e.g., for inputdialog().
Using "
<silent>" for an abbreviation is possible, but will cause redrawing of the command line to fail.
:h map-silent– VanLaser Dec 16 '15 at 18:26<silent>does it! – Dec 17 '15 at 09:56<Esc>, you might like to read the following question and its answers, too: https://vi.stackexchange.com/questions/2614/why-does-this-esc-nmap-affect-startup. – Rich Jan 19 '16 at 09:21