Fri, 22 Nov 2019 23:07:56 -0600
use cword as ag/rg default
.vim/autoload/vimrc.vim | file | annotate | diff | comparison | revisions | |
.vimrc | file | annotate | diff | comparison | revisions |
--- a/.vim/autoload/vimrc.vim +++ b/.vim/autoload/vimrc.vim @@ -43,8 +43,10 @@ func! vimrc#Ag(args) abort set t_ti= t_te= let &shellpipe = substitute(&shellpipe, '| tee', ' >', '') + let grepargs = a:args == '' ? expand('<cword>') : a:args . join(a:000, ' ') + try - silent! execute "grep " . escape(a:args . join(a:000, ' '), '|') + silent! execute "grep " . escape(grepargs, '|') copen let @/ = matchstr(a:args, "\\v(-)\@<!(\<)\@<=\\w+|['\"]\\zs.{-}\\ze['\"]")
--- a/.vimrc +++ b/.vimrc @@ -105,7 +105,7 @@ nnoremap <silent> <leader><leader>k :cal nmap <leader>l V<leader>k " use Ag for a recursive * -nnoremap g* :Ag <cword><CR> +nnoremap g* :Ag<CR> " K: doc, gKK: doc current filename nnoremap gKK :call ViewDoc('doc', expand('%:p'))<CR> @@ -131,7 +131,7 @@ command! Mksession execute "mksession! " command! -nargs=* -complete=file Tig call tig#Tig(<f-args>) command! TigBlame call tig#TigBlame() -command! -nargs=+ -complete=file -bar Ag call vimrc#Ag(<q-args>) +command! -nargs=* -complete=file -bar Ag call vimrc#Ag(<q-args>) CAlias Rg Ag CAlias Q q