Created
May 16, 2014 20:01
-
-
Save Dkendal/9c5244f04755f0eb7e3e to your computer and use it in GitHub Desktop.
A vim operator function to search for a word with a motion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nnoremap <leader>g :set operatorfunc=AgOperator<cr>g@ | |
vnoremap <leader>g :<c-u>call AgOperator(visualmode())<cr> | |
function! AgOperator(type) | |
if a:type ==# 'v' | |
normal! `<v`>y | |
elseif a:type ==# 'char' | |
normal! `[v`]y | |
else | |
return | |
endif | |
silent execute "Ag " . shellescape(@@) . " ." | |
copen | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment