Mercurial > dotfiles.old
diff vimrc @ 236:639222e1ab7b
Add Ag plugin
author | zegervdv <zegervdv@me.com> |
---|---|
date | Sat, 07 Feb 2015 22:12:55 +0100 |
parents | 4ebdb386a987 |
children | b3bf31ff1c1c |
line wrap: on
line diff
--- 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 <silent> \a :set opfunc=<SID>AckMotion<CR>g@ +xnoremap <silent> \a :<C-U>call <SID>AckMotion(visualmode())<CR> + +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(@@) . "\<cr>" + + let @@ = reg_save +endfunction +" }}} " Load local vimrc if filereadable($HOME . "/.vimrc.local")