While there is <up>
and <down>
that tries to complete the line, sometimes one wants to recall all the commands that start with what was typed, on a (wild)menu.
Is this possible somehow?
I was able to use FZF to complete the command by using the command history.
Unfortunately, I had to get out of the command line to do so, but it still fairly comfortable. I could edit the command afterwards if I want to.
function! GetCommands()
let lines=[]
let nu=histnr("cmd")
for i in range(1,nu)
let lines+=[histget("cmd",i)]
endfor
return lines
endfunction
function! HandleCommand(item)
call feedkeys("q:")
call feedkeys("G?\\V".escape(a:item,'\/?')."\<CR>")
endfunction
function! CompleteCommand(arg)
call fzf#run({'source': GetCommands(),'sink': function('HandleCommand'),'options': '-m --query "'.a:arg.'"'} )
endfunction
:cmap <expr> <c-a> &cedit.'^"xy$'."<esc><esc>:call CompleteCommand(@x)<CR>"
:autocmd CmdwinEnter * map <buffer> <ESC> <C-c><C-c>