Created
May 13, 2014 20:50
-
-
Save kristianfreeman/a3895b1b0d068d3cc3bd to your computer and use it in GitHub Desktop.
really, really fast vim filtering
This file contains hidden or 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
" Requirements: | |
" selecta: https://github.com/garybernhardt/selecta | |
" ag: https://github.com/ggreer/the_silver_searcher | |
" Run a given vim command on the results of fuzzy selecting from a given shell | |
" command. See usage below. | |
function! SelectaCommand(choice_command, selecta_args, vim_command) | |
try | |
silent let selection = system(a:choice_command . " | selecta " . a:selecta_args) | |
catch /Vim:Interrupt/ | |
" Swallow the ^C so that the redraw below happens; otherwise there will be | |
" leftovers from selecta on the screen | |
redraw! | |
return | |
endtry | |
redraw! | |
exec a:vim_command . " " . selection | |
endfunction | |
" Find all files in all non-dot directories starting in the working directory. | |
" Fuzzy select one of those. Open the selected file with :e. | |
nnoremap <c-p> :call SelectaCommand("ag --no-numbers --nogroup -l .", "", ":e")<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment