"git grep the current word using K (mnemonic Kurrent) nnoremap K :GitGrep 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 "git grep visual selection vnoremap K :execute GitGrep(GetVisual()) "git grep current word up to the next exclamation point using ,K nnoremap ,K viwf!:execute GitGrep(GetVisual()) "grep for 'def foo' nnoremap ,gd :GitGrep 'def '