From 4a2bd58c99369869798fc937492dc2d3f28e57ff Mon Sep 17 00:00:00 2001 From: yan Date: Fri, 20 Jan 2012 19:17:35 -0800 Subject: [PATCH] ,K - Git grep up to next exclamation. Useful for ruby method grepping --- README.md | 3 ++- vim/plugin/settings/git-grep.vim | 20 ++++++++++++++++++++ vim/plugin/settings/skwp-keymap.vim | 3 --- 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 vim/plugin/settings/git-grep.vim diff --git a/README.md b/README.md index 53ac809..9291ecc 100644 --- a/README.md +++ b/README.md @@ -189,7 +189,8 @@ files contain key mappings as well (TODO: probably will move them out to skwp-ke **Search/Code Navigation** * ,f - instantly Find definition of class (must have exuberant ctags installed) - * K - GitGrep the current word under the cursor and show results in quickfix window + * K - GitGrep the current word under the cursor and show results in quickfix window + * ,K - GitGrep the current word up to next exclamation point (useful for ruby foo! methods) * Cmd-* - highlight all occurrences of current word (similar to regular * except doesn't move) * ,hl - toggle search highlight on and off * ,gg - GitGrep command line with a quote pretyped (close the quote yourself) diff --git a/vim/plugin/settings/git-grep.vim b/vim/plugin/settings/git-grep.vim new file mode 100644 index 0000000..386ba16 --- /dev/null +++ b/vim/plugin/settings/git-grep.vim @@ -0,0 +1,20 @@ +"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()) + diff --git a/vim/plugin/settings/skwp-keymap.vim b/vim/plugin/settings/skwp-keymap.vim index 337f89a..a308c3a 100644 --- a/vim/plugin/settings/skwp-keymap.vim +++ b/vim/plugin/settings/skwp-keymap.vim @@ -85,9 +85,6 @@ nnoremap ,f "toggle between last two buffers with Z (normally ctrl-shift-6) nnoremap ,z -"git grep the current word using K (mnemonic Kurrent) -nnoremap K :GitGrep - " ============================== " Window/Tab/Split Manipulation " ==============================