aboutsummaryrefslogblamecommitdiff
path: root/vim/config/search.vim
blob: ff24311633b1b3d4c4dd37b7efda37190228a824 (plain) (tree)
1
2
3
4
5
6
7
8




                                                    


                                                  


                                             


                                                



                                                                         


                                   


                                                                            
                                       
                              
              





                                 


               
" Some special settings for searching, if available
if has('extra_search')

  " Searching as I enter my pattern, \i toggles this
  set incsearch
  nnoremap <silent>
        \ <Leader>i
        \ :<C-U>setlocal incsearch! incsearch?<CR>

  " Highlight search results, \h toggles this
  set hlsearch
  nnoremap <silent>
        \ <Leader>h
        \ :<C-U>setlocal hlsearch! hlsearch?<CR>

  " Pressing ^L will clear highlighting until the next search-related
  " operation; quite good because the highlighting gets distracting after
  " you've found what you wanted
  nnoremap <silent>
        \ <C-L>
        \ :<C-U>nohlsearch<CR><C-L>

  " Clear search highlighting as soon as I enter insert mode, and restore it
  " once I leave it
  if has('autocmd') && v:version >= 701
    augroup dotfiles_highlight
      autocmd!
      autocmd InsertEnter
            \ *
            \ setlocal nohlsearch
      autocmd InsertLeave
            \ *
            \ setlocal hlsearch
    augroup END
  endif
endif