aboutsummaryrefslogtreecommitdiff
path: root/vim/config/search.vim
blob: 0f10eea59de55c463afbbca115df6419d7bc2234 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
" Some special settings for searching, if available
if has('extra_search')

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

  " Highlight search results, \h toggles this
  set hlsearch
  nnoremap <Leader>h :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> :nohlsearch<CR><C-l>

  " Clear search highlighting as soon as I enter insert mode, and restore it
  " once I leave it
  if has('autocmd')
    augroup dotfiles_highlight
      autocmd!
      silent! autocmd InsertEnter * setlocal nohlsearch
      silent! autocmd InsertLeave * setlocal hlsearch
    augroup END
  endif
endif