Nick Cripps schrieb:
> Hi,
> I've been using emacs for a while and recently decided that I'm fed up
> with it. vim looks like it will suit me much better, but I'm still
> learning to use it.
>
> One thing I don't like so much is the search highlighting behavior. In
> emacs matches are highlighted while you type the expression (which
> I've found you can enable in vim by adding :set incsearch to .vimrc)
> and continue to be highlighted until you do anything not related to
> searching (such as move the cursor).
>
> What I would like is to have all matches highlighted from when I
> perform the search and stay highlighted only until I press any key
> other than n or N (ie emacs highlighting behavior).
>
> I've tried googling for an answer but not found anything. Anyone know
> how I can get this?
>
> Thanks,
> Nick
You can map a key to :nohlsearch
:h :noh
:noremap <Leader>h :<C-U>nohlsearch<CR>
which is the usual approach.
Or you can put the following in a script file and :source it
(not deeply tested, but works ok for me).
It will put the keys n and N in a special mode after searching
with /pat or ?pat .
cmap <expr> <CR> getcmdtype()=~'[/?]'
\ ? '<CR><Plug>EmacsSearchHl'
\ : '<CR>'
" careful: some other plugins (fuzzyfinder?) also map <CR> in Cmdline
" mode
map n n<Plug>EmacsSearchHl
map N N<Plug>EmacsSearchHl
omap n n<SID>stop
omap N N<SID>stop
sunmap n
sunmap N
map <Plug>EmacsSearchHl <SID>start<SID>m_
" TODO
vmap <Plug>EmacsSearchHl <Nop>
no <silent> <SID>start :<C-U>call <sid>Start()<CR>
no <silent> <SID>stop :<C-U>nohlsearch<Bar>call <sid>Stop()<CR>
nn <script> <SID>m_n n<SID>m_
nn <script> <SID>m_N N<SID>m_
nmap <SID>m_ <SID>stop
func! <sid>Start()
if s:quitnormal
let s:sav_tm = &timeoutlen
let s:quitnormal = 0
endif
set timeoutlen=60000
endfunc
func! <sid>Stop()
if !s:quitnormal
let &timeoutlen = s:sav_tm
let s:quitnormal = 1
endif
endfunc
let s:quitnormal = 1
--
Andy
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---