search.vim 1003 B

123456789101112131415161718192021222324252627282930
  1. " Backspace to clear current search (and stop highlighting)
  2. nnoremap <silent> <backspace> :call ClearSearch()<CR>
  3. function! ClearSearch()
  4. if (@/ != "")
  5. let @/=""
  6. redraw
  7. endif
  8. endfunction
  9. " use faster search tools if available
  10. if executable('ag')
  11. set grepprg=ag\ --vimgrep\ $*
  12. set grepformat=%f:%l:%c:%m
  13. elseif executable('ack')
  14. set grepprg=ack\ --with-filename\ --nocolor\ --nogroup\ --column
  15. elseif executable('ack-grep')
  16. set grepprg=ack-grep\ --with-filename\ --nocolor\ --nogroup\ --column
  17. endif
  18. " don't display ack/grep terminal output. NOTE: not reliable
  19. " https://github.com/mileszs/ack.vim/issues/18
  20. "set shellpipe=&>
  21. " EasyGrep settings.
  22. let g:EasyGrepCommand = 1 " Default to grepprg instead of vimgrep.
  23. let g:EasyGrepRecursive = 1
  24. let g:EasyGrepReplaceWindowMode = 2 " `Replace` in same window, not tabs/splits
  25. let g:EasyGrepFilesToExclude=".git" " Exclude dirs for `ack` and `grep`
  26. let g:EasyGrepRoot = "search:.git,.hg,.svn" " Repo-aware when possible.