Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add selecta

  • Loading branch information...
commit 27846cb029e20587396db9b481c839f7c0acb261 1 parent f8ef3f2
@lmarburger authored
Showing with 19 additions and 0 deletions.
  1. +19 −0 vimrc
View
19 vimrc
@@ -283,3 +283,22 @@ endfunction
nmap <leader>. :call RunTestFile()<CR>
nmap <leader>> :silent :!clear<cr>:w<cr>:!ruby -Ilib %<cr>
+
+" 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 <leader>f :call SelectaCommand("git ls-files", "", ":e")<cr>
Please sign in to comment.
Something went wrong with that request. Please try again.