I currently have <Enter>
mapped to :nohlsearch
in normal mode. This allows me to leave search highlighting on for all new searches, but easily turn it off when it (soon after usually) becomes a distraction.
This works great usually, the exception is when I'm using q:
to edit the command history to produce a closely related ex command or whatever. The behavior of Enter in that context is to execute the command (or search in search history edit), but the normal-mode remapping overrides that. Consequently, I need to hit enter from insert mode to execute the command.
How can I map Enter to :nohlsearch
in normal mode but retain the "execute" behavior of Enter in the command-history edit window?