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
<silent>
does it!