0

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?

1 Answer 1

0

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.