Open aymericbeaumet opened 7 years ago
Interesting idea, I'll think about the options when I get some time.
I managed to come up with a solution allowing to:
:
and /
, ignoring other getcmdtype()
's'
and "
I would be glad to hear your feedback on this:
function! s:FzfCommandHistory()
let s:INTERRUPT = "\u03\u0c" " <C-c><C-l>
let s:SUBMIT = "\u0d" " <C-m>
let s:cmdtype = getcmdtype()
let s:args = string({
\ "options": "--query=" . shellescape(getcmdline()),
\ })
if s:cmdtype == ':'
return s:INTERRUPT . ":keepp call fzf#vim#command_history(" . s:args . ")" . s:SUBMIT
elseif s:cmdtype == '/'
return s:INTERRUPT . ":keepp call fzf#vim#search_history(" . s:args . ")" . s:SUBMIT
else
return ''
endif
endfunction
cnoremap <expr> <C-r> <SID>FzfCommandHistory()
Thanks 👍
Looks good. I'll see if there's any room for improvement and consider including it in the repo as a <plug>
map.
My goal is to mimic fzf behaviour when searching the Zsh history with
<C-R>
, the behaviour I expect in vim is::
or the/
command line modes:History:
or:History/
commands with the<C-R>
mappingquery
parameter, so that I don't have to type twice I already started the commandI came up with the following solution, but I find it very shaky and I believe there would be a cleaner way to do it. Plus it pollutes the history, doesn't support
"
in the commands and only works for:
.The issue is that in order to execute a function from the command line you have to alter it. So I hardly see how it's doable. Any idea?