function! GetVisual()
  let reg_save = getreg('"')
  let regtype_save = getregtype('"')
  let cb_save = &clipboard
  set clipboard&
  normal! ""gvy
  let selection = getreg('"')
  call setreg('"', reg_save, regtype_save)
  let &clipboard = cb_save
  return selection
endfunction

"grep the current word using K (mnemonic Kurrent)
nnoremap <silent> K :Ag <cword><CR>

"grep visual selection
vnoremap K :<C-U>execute "Ag " . GetVisual()<CR>

"grep current word up to the next exclamation point using ,K
nnoremap ,K viwf!:<C-U>execute "Ag " . GetVisual()<CR>

"grep for 'def foo'
nnoremap <silent> ,gd :Ag 'def <cword>'<CR>

",gg = Grep! - using Ag the silver searcher
" open up a grep line, with a quote started for the search
nnoremap ,gg :Ag ""<left>

"Grep Current Partial
function! AgCurrentPartial()
  let l:fileNameWithoutExtension = expand('%:t:r')
  let l:fileNameWithoutUnderscore = substitute(l:fileNameWithoutExtension, '^_','','g')
  let l:grepPattern = "render.*[\\\'\\\"].*" . l:fileNameWithoutUnderscore . "[\\\'\\\"]$"
  exec 'Ag "' . l:grepPattern . '"'
endfunction

command! AgCurrentPartial call AgCurrentPartial()
"
nnoremap ,gcp :AgCurrentPartial<CR>

"Grep for usages of the current file
nnoremap ,gcf :exec "Ag " . expand("%:t:r")<CR>

function! GetVisual()
  let reg_save = getreg('"')
  let regtype_save = getregtype('"')
  let cb_save = &clipboard
  set clipboard&
  normal! ""gvy
  let selection = getreg('"')
  call setreg('"', reg_save, regtype_save)
  let &clipboard = cb_save
  return selection
endfunction

"grep the current word using K (mnemonic Kurrent)
nnoremap <silent> K :Ag <cword><CR>

"grep visual selection
vnoremap K :<C-U>execute "Ag " . GetVisual()<CR>

"grep current word up to the next exclamation point using ,K
nnoremap ,K viwf!:<C-U>execute "Ag " . GetVisual()<CR>

"grep for 'def foo'
nnoremap <silent> ,gd :Ag 'def <cword>'<CR>

",gg = Grep! - using Ag the silver searcher
" open up a grep line, with a quote started for the search
nnoremap ,gg :Ag ""<left>

"Grep for usages of the current file
nnoremap ,gcf :exec "Ag " . expand("%:t:r")<CR>

Remove grep current partial, doesn't work well
Remove grep current partial, doesn't work well
mente/dotfiles,kylewest/yadr,wesson-yi/dotfiles,lfilho/dotfiles,daxgames/dotfiles,skwp/dotfiles,leiklier/dotfiles,K3yChain/yadr,andrewSC/dotfiles,mdarnall/dotfiles,kqyang/dotfiles,ds82/dotfiles,K3yChain/yadr,minhoolee/skwp-dotfiles,cantoraz/yadr,skjerven/dotfiles,yjlintw/dotfiles,patarra/dotfiles,wesson-yi/dotfiles,svdberg/dotfiles,uhjish/dotfiles,cantoraz/yadr,atsapov/dotfiles,svdberg/dotfiles,41407/dotfiles,periodic1236/dotfiles,drajguru/dotfiles,mente/dotfiles,plribeiro3000/dotfiles,zelga/dotfiles,tonynguyen68/dotfiles,jameszaghini/dotfiles,argami/dotfiles,akitaonrails/dotfiles,tallamjr/yadr-fork,epelz/dotfiles,swanandp/dotfiles,skjerven/dotfiles,Xiaobin0860/dotfiles,rockwarrior/dotfiles,xkonni/dotfiles,stevenbarragan/dotfiles,LouTheBrew/dotfiles,jckdrpr/dotfiles-1,qianthinking/dotfiles,sztupy/dotfiles,aqibmushtaq/dotfiles,nakolkin/dotfiles,xvaara/dotfiles,stinoga/dotfiles-1,tkuichooseyou/dotfiles,tonynguyen68/dotfiles,flyingfsck/dotfiles,jby/dotfiles,tigershen23/dotfiles,qianthinking/dotfiles,aeikenberry/yardr_dotfiles,ay65535/yadr,kqyang/dotfiles,auser/yadr,alex-wood/dotfiles,davepgreene/yadr,giorni/dotfiles,goorockey/dotfiles,tmullen/dotfiles,nakolkin/dotfiles,ds82/dotfiles,SherrySeibel/dotfiles,hophacker/dotfiles,kanche/dotfiles,daxgames/dotfiles,Xiaobin0860/dotfiles,uhjish/dotfiles,zelga/dotfiles,thekindofme/dotfiles,alex-wood/dotfiles,leiklier/dotfiles,captainmike/dotfiles,ay65535/yadr,andrewSC/dotfiles,walkleyn/dotfiles,goorockey/dotfiles,stinoga/dotfiles-1,stevenbarragan/dotfiles,hophacker/dotfiles,tigershen23/dotfiles,mdarnall/dotfiles,yjlintw/dotfiles,lfilho/dotfiles,bobek/dotfiles,kqyang/dotfiles,Sumukh/dotfiles,epelz/dotfiles,captainmike/dotfiles,btroo/dotfiles,btroo/dotfiles,uhjish/dotfiles,davepgreene/yadr,aqibmushtaq/dotfiles,kierangraham/dotfiles,jameszaghini/dotfiles,trongrg/dotfiles,ramiroaraujo/dotfiles,uhjish/dotfiles,Sumukh/dotfiles,thekindofme/dotfiles,yjlintw/dotfiles,tkuichooseyou/dotfiles,skjerven/dotfiles,diego-oliveira/dotfiles-1,ignasi/dotfiles,kierangraham/dotfiles,argyakrivos/dotfiles,ccll/dotfiles,uhjish/dotfiles,uhjish/dotfiles,minhoolee/skwp-dotfiles,41407/dotfiles,kanche/dotfiles,lfilho/dotfiles,auser/yadr,jo-tez/yadr,SherrySeibel/dotfiles,ramiroaraujo/dotfiles,argyakrivos/dotfiles,ds82/dotfiles,trongrg/dotfiles,swanandp/dotfiles,argami/dotfiles,kierangraham/dotfiles,minhoolee/skwp-dotfiles,drajguru/dotfiles,minhoolee/skwp-dotfiles,hulajesus/dotfiles,walkleyn/dotfiles,denyago/dotfiles,tmullen/dotfiles,RyanMacG/dotfiles-1,hulajesus/dotfiles,qianthinking/dotfiles,flyingfsck/dotfiles,jckdrpr/dotfiles-1,kylewest/yadr,wesson-yi/dotfiles,tallamjr/yadr-fork,plribeiro3000/dotfiles,andrewSC/dotfiles,jo-tez/yadr,pswaminathan/dotfiles,jckdrpr/dotfiles-1,skwp/dotfiles,akitaonrails/dotfiles,mente/dotfiles,RyanMacG/dotfiles-1,giorni/dotfiles,joesus/dotfiles,joesus/dotfiles,denyago/dotfiles,xkonni/dotfiles,LouTheBrew/dotfiles,rockwarrior/dotfiles,patarra/dotfiles,aeikenberry/yardr_dotfiles,uhjish/dotfiles,ignasi/dotfiles,uhjish/dotfiles,bobek/dotfiles,ccll/dotfiles,diego-oliveira/dotfiles-1,pswaminathan/dotfiles,kierangraham/dotfiles,xvaara/dotfiles,periodic1236/dotfiles,atsapov/dotfiles,sztupy/dotfiles,uhjish/dotfiles,jby/dotfiles