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?

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>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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