diff --git a/vimrc b/vimrc index 28e6cb6..bf3565b 100644 --- a/vimrc +++ b/vimrc @@ -201,11 +201,6 @@ nnoremap 4 :! p4 edit % " open vsplit and switch to it nnoremap v vl -" Ack -nnoremap a :Ack -" use ag -let g:ackprg = 'ag --nogroup --nocolor --column' - " Buffer selection nnoremap l :ls:b @@ -269,3 +264,27 @@ let g:calendar_google_calendar = 1 map / (incsearch-forward) map ? (incsearch-backward) map g/ (incsearch-stay) + +" Ack +"nnoremap a :Ack +" No wait, Ack motion! Thanks again sjl +nnoremap a :set opfunc=AckMotiong@ +xnoremap a :call AckMotion(visualmode()) + +function! s:CopyMotionForType(type) + if a:type ==# 'v' + silent execute "normal! `<" . a:type . "`>y" + elseif a:type ==# 'char' + silent execute "normal! `[v`]y" + endif +endfunction + +function! s:AckMotion(type) abort + let reg_save = @@ + + call s:CopyMotionForType(a:type) + + execute "normal! :Ack! --literal " . shellescape(@@) . "\" + + let @@ = reg_save +endfunction