Using autocommands, you can make search highlighting transient, activating when
you enter a search, and deactivating on your next cursor movement:
set incsearch nohlsearch
augroup hl_init
au! CmdlineEnter [/\?] call InitHighlight()
augroup END
func! InitHighlight()
set hlsearch
augroup hl_decay
au! CursorMoved * call DecayHighlight()
augroup END
endf
func! DecayHighlight()
augroup hl_decay
au! CursorMoved * set nohlsearch
augroup END
endf
This works well for the most part, but if you cancel a search (e.g. <Esc>),
you'll end up with a previous search pattern highlighted.
Ideally there'd be a way to distinguish such cancellations from other means of
leaving the command line. There doesn't seem to be a way to do this currently.
There's a CmdLineLeave autocommand event, but it's broadcast regardless of how
you exited the command line.
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.