Created
June 8, 2016 12:19
-
-
Save ErikCorryGoogle/417755c0e3b2545d445bb15154a9a627 to your computer and use it in GitHub Desktop.
.vimrc file for Ggrep key binding
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
" Does a git grep of whatever you are currently searching for. Requires | |
" fugitive.vim | |
" Bugs: | |
" Always does a case dependent search, even if vim is ignorecase mode. | |
" Doesn't understand searches with spaces in them (usually you can just | |
" replace spaces with dots in the Vim search). | |
" Doesn't understand most metacharacters that also mean something to the | |
" shell. | |
" Understands \<word\> and converts to a grep -w, but doesn't understand | |
" asymmetric word delimiters like \<word or word\> | |
function! GgrepFromSearch() | |
let searchterm = @/ | |
echo searchterm | |
let stripped = matchlist(searchterm, '^\\<\(.*\)\\>$') | |
if (len(stripped) != 0) | |
execute "silent! Ggrep -w " . stripped[1] | |
else | |
execute "silent! Ggrep " . searchterm | |
endif | |
redraw! | |
endfunction | |
" If there's a vertical split, this opens the search in the right side. | |
" If there is no vertical split, just does the search in the current window. | |
" If you accidentally do the search in the current window, use :b# to go back. | |
map å <C-W>l:call GgrepFromSearch()<CR> | |
" Creates a vertical split and does the search in the right hand one. | |
map Å :vspl<CR><C-W>l:call GgrepFromSearch()<CR> | |
" For moving back and forth through the Ggrep result. | |
map æ :cprevious<CR> | |
map ø :cnext<CR> |
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
" Looks at the character to the left, and does a shell-style autocomplete | |
" (ctrl-P) if we are in the middle of a word. If there is white-space | |
" or beginning-of-line, it does two spaces to indent. | |
function! CleverTab() | |
if strpart( getline('.'), col('.')-2, 1) =~ '^\s*$' | |
return " " | |
else | |
return "\<C-P>" | |
endfunction | |
inoremap <Tab> <C-R>=CleverTab()<CR> |
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
" Map shift-arrow to navigate between windows. | |
map <S-Up> <C-W>k | |
map <S-Down> <C-W>j | |
map <S-Right> <C-W>l | |
map <S-Left> <C-W>h | |
" Make split vertically larger | |
map Q 10<C-W>+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment