From 2f0ba3df092e0916a7886b5d3e65f35dab505da8 Mon Sep 17 00:00:00 2001 From: Dustin Swan Date: Sat, 27 Dec 2014 15:35:49 -0600 Subject: [PATCH] Ack Motion for Vim --- vimrc | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) 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