Skip to content

Instantly share code, notes, and snippets.

@coryf
Last active December 12, 2018 19:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coryf/87adb964b3ca1163fbc8081f62a488c2 to your computer and use it in GitHub Desktop.
Save coryf/87adb964b3ca1163fbc8081f62a488c2 to your computer and use it in GitHub Desktop.
Vim ripgrep and fzy
" ripgrep
" https://github.com/BurntSushi/ripgrep
set grepprg=rg\ --vimgrep\ --no-heading
set grepformat^=%f:%l:%c:%m
command -nargs=+ -complete=file Rg silent! grep! <args> | copen | redraw!
nmap <silent> <leader>a :Rg "\b<C-R><C-W>\b"<CR>
" fzy - fuzzy find
" https://github.com/jhawthorn/fzy
function! FzyCommand(choice_command, vim_command)
try
let output = system(a:choice_command . " | fzy ")
catch /Vim:Interrupt/
" Swallow errors from ^C, allow redraw! below
endtry
redraw!
if v:shell_error == 0 && !empty(output)
exec a:vim_command . ' ' . output
endif
endfunction
nnoremap <leader>t :call FzyCommand("rg . -l -g ''", ":e")<cr>
@coryf
Copy link
Author

coryf commented Apr 25, 2017

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