# HG changeset patch # User zegervdv # Date 1423343575 -3600 # Node ID 639222e1ab7b70f69997cf2e06e19b1a55feefc4 # Parent d29157c632c0c813ee2da970fa5203562af289f0 Add Ag plugin diff -r d29157c632c0 -r 639222e1ab7b vimrc --- a/vimrc Fri Jan 30 16:08:56 2015 +0100 +++ b/vimrc Sat Feb 07 22:12:55 2015 +0100 @@ -32,6 +32,7 @@ " Moving in files Plug 'wellle/targets.vim' +Plug 'rking/ag.vim' " Command line Plug 'tpope/vim-eunuch', { 'on' : ['Remove', 'Unlink', 'Move', 'Rename', 'Mkdir', 'Chmod', 'Find', 'Locate', 'SudoEdit', 'SudoWrite']} @@ -441,6 +442,29 @@ " Swoop {{{ let g:swoopUseDefaultKeyMap = 0 " }}} +" Ag {{{ +" Ack motions by Steve Losh, adapted for Ag +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! :Ag --literal " . shellescape(@@) . "\" + + let @@ = reg_save +endfunction +" }}} " Load local vimrc if filereadable($HOME . "/.vimrc.local")