Refactor search fn in vimrc
This commit is contained in:
parent
cbf3d73649
commit
125880e665
35
vimrc
35
vimrc
|
@ -341,7 +341,7 @@ augroup campoCmds
|
||||||
|
|
||||||
" Generate ctags
|
" Generate ctags
|
||||||
" Include local variables for c languages.
|
" Include local variables for c languages.
|
||||||
au BufWritePost *.py,*.c,*.cpp,*.h silent! !eval 'ctags --c-types=+l --c++-types=+l -R -o newtags; mv newtags tags' &
|
au BufWritePost *.py,*.c,*.cpp,*.h silent! !eval 'ctags --c-types=+l --c++-types=+l --exclude=vendor -R -o newtags; mv newtags tags' &
|
||||||
|
|
||||||
" Remove trailing whitespace on save all files.
|
" Remove trailing whitespace on save all files.
|
||||||
function! <SID>StripTrailingWhitespaces()
|
function! <SID>StripTrailingWhitespaces()
|
||||||
|
@ -477,7 +477,7 @@ map <leader>v :e %:p:s,.h$,.X123X,:s,.cpp$,.h,:s,.X123X$,.cpp,<CR>
|
||||||
"map <leader>vvv :e %:p:s,.h$,.X123X,:s,.cc$,.h,:s,.X123X$,.cc,<CR>
|
"map <leader>vvv :e %:p:s,.h$,.X123X,:s,.cc$,.h,:s,.X123X$,.cc,<CR>
|
||||||
|
|
||||||
" Replace all instances of the highlighted text with whatever you enter.
|
" Replace all instances of the highlighted text with whatever you enter.
|
||||||
nnoremap <c-s> :%s///g<left><left>
|
nnoremap <c-g> :%s///g<left><left>
|
||||||
|
|
||||||
"////////////////////////////////////////////////////////////////
|
"////////////////////////////////////////////////////////////////
|
||||||
" QUICKLY OPEN C++ SOURCE OR HEADER FILE
|
" QUICKLY OPEN C++ SOURCE OR HEADER FILE
|
||||||
|
@ -961,25 +961,34 @@ endfunction
|
||||||
map <leader>gg :call GlobalReplaceIt(0)<cr>
|
map <leader>gg :call GlobalReplaceIt(0)<cr>
|
||||||
map <leader>gr :call GlobalReplaceIt(1)<cr>
|
map <leader>gr :call GlobalReplaceIt(1)<cr>
|
||||||
|
|
||||||
function! Search()
|
function! Search(case_insensitive)
|
||||||
let l:term = input('Grep search term: ')
|
let helper = "[" . (a:case_insensitive ? "case-insensitive" : "case-sensitive") . "] search: "
|
||||||
if empty(l:term)
|
let term = input(helper)
|
||||||
|
if empty(term)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
if IsWindows()
|
|
||||||
"Fsgrep is slow...."
|
|
||||||
"exec 'Fsgrep "' . l:term . '"'
|
|
||||||
|
|
||||||
"@note --pretty (i.e. colors) is not enabled in vim-ripgrep because the
|
"@note --pretty (i.e. colors) is not enabled in vim-ripgrep because the
|
||||||
"quickfix window doesn't seem to parse the ansi color codes.
|
"quickfix window doesn't seem to parse the ansi color codes.
|
||||||
exec 'Rg --trim --ignore-case -g "!vendor/*" "' . l:term . '"'
|
let rg_args = "--trim -g \"!vendor/*\""
|
||||||
|
|
||||||
|
if a:case_insensitive
|
||||||
|
let rg_args .= " --ignore-case"
|
||||||
|
endif
|
||||||
|
|
||||||
|
if IsWindows()
|
||||||
|
"@deprecated: Fsgrep is slow...."
|
||||||
|
"exec 'Fsgrep "' . term . '"'
|
||||||
|
exec 'Rg ' . rg_args . ' "' . term . '"'
|
||||||
else
|
else
|
||||||
"exec 'Ag "' . l:term . '"'
|
"@deprecated: ripgrep is faster than Ag.
|
||||||
" ripgrep is faster than Ag.
|
"exec 'Ag "' . term . '"'
|
||||||
execute 'Find '.l:term
|
" @incomplete pass case sensitivity toggle to Find.
|
||||||
|
execute 'Find ' . term
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
map <leader>s :call Search()<cr>
|
map <leader>s :call Search(1)<cr>
|
||||||
|
map <leader>ss :call Search(0)<cr>
|
||||||
|
|
||||||
" Navigation for the vim-ripgrep search results.
|
" Navigation for the vim-ripgrep search results.
|
||||||
" Hit o on a result line to open the file at that line.
|
" Hit o on a result line to open the file at that line.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user