Skip to content

Instantly share code, notes, and snippets.

@drasill
Last active November 25, 2016 12:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drasill/adb258e1363a22e6e433 to your computer and use it in GitHub Desktop.
Save drasill/adb258e1363a22e6e433 to your computer and use it in GitHub Desktop.
function! s:escape(path)
return substitute(a:path, ' ', '\\ ', 'g')
endfunction
function! GitGrepHandler(line)
let parts = split(a:line, ':')
let [fn, lno] = parts[0 : 1]
execute 'e '. s:escape(fn)
execute lno
normal! zz
endfunction
command! -nargs=+ Fgg call fzf#run({
\ 'source': 'git grep -n -I --untracked -i "<args>"',
\ 'sink': function('GitGrepHandler'),
\ 'options': '+m',
\ 'tmux_height': '60%'
\ })
@drasill
Copy link
Author

drasill commented Nov 19, 2015

To use it with vim-plug :

Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'https://gist.github.com/adb258e1363a22e6e433.git',
    \ { 'dir': g:plug_home.'/vim-fzf-git-grep/plugin', 'rtp': '..' }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment