Hi,

I like and use Highlighting() from
http://vim.wikia.com/wiki/Highlight_all_search_pattern_matches

    " Smart <Enter> for highlighting
    let g:highlighting = 0
    function! Highlighting()
      if g:highlighting == 1 && @/ =~ '^\\<'.expand('<cword>').'\\>$'
        let g:highlighting = 0
        return ":silent nohlsearch\<CR>"
      endif
      let @/ = '\<'.expand('<cword>').'\>'
      let g:highlighting = 1
      return ":silent set hlsearch\<CR>"
    endfunction
    "nnoremap <silent> <expr> <CR> Highlighting()

    " remove highlighting
    :nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR>

Unfortunately, it breaks quickfix; after pressing <CR> in the quickfix
window, nothing happens.

I have tried to counter this problem by adding

      if &buftype == "quickfix"
          return 'execute "normal! <CR>"'
      endif

to the start of the function, but then I get an error message
complaining that the quickfix window is not modifiable. So, I guess

normal! <CR>

is not the proper thing to say in the quickfix window. What is? How can
I make this function not break quickfix?

Thank you for any suggestions,

Matěj Cepl
-- 
http://www.ceplovi.cz/matej/, Jabber: [email protected]
GPG Finger: 89EF 4BC6 288A BF43 1BAB  25C3 E09F EF25 D964 84AC

They that can give up essential liberty to obtain a little
temporary safety deserve neither liberty nor safety.
    -- Benjamin Franklin, Historical Review
       of Pennsylvania, 1759.



Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to