Skip to content

Instantly share code, notes, and snippets.

@davidmh
Created September 16, 2015 18:11
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidmh/bc21331b95ae6c9fe280 to your computer and use it in GitHub Desktop.
Save davidmh/bc21331b95ae6c9fe280 to your computer and use it in GitHub Desktop.
reverse-i-search for vim with fzf
" reverse-i-search
function! s:get_history()
redir => history
silent! history
redir END
return map(split(history, '\n'), "strpart(v:val, 9)")
endfunction
function! s:run_cmd(cmd)
execute a:cmd
endfunction
command! FZFCmds call fzf#run({
\ 'source': <sid>get_history(),
\ 'sink': function('<sid>run_cmd'),
\ 'options': '-x --tac +s --prompt="cmd >"',
\ 'right': '40%'})
nnoremap <leader>r :FZFCmds<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment