On 27 May 2009, at 13:22, Andy Wokula wrote:

> You can map a key to :nohlsearch
>    :h :noh
>    :noremap <Leader>h :<C-U>nohlsearch<CR>
> which is the usual approach.

That is nice and flexible.
>
>
> 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
>
>
I will try using both and see which I prefer after a bit of use.

Thanks a lot!

Nick

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to