diff --git a/examples.md b/examples.md index b3da648..a707e58 100644 --- a/examples.md +++ b/examples.md @@ -226,41 +226,50 @@ Fuzzy cmdline completion ```vimL cnoremap eGetCompletions() +"add an extra at the end of this line to automatically accept the fzf-selected completions. function! Lister() - call extend(g:FZF_Cmd_Completion_Pre_List,split(getcmdline(),' ')) + call extend(g:FZF_Cmd_Completion_Pre_List,split(getcmdline(),'\(\\\zs\)\@\eLister()\\" let l:FZF_Cmd_Completion_List = g:FZF_Cmd_Completion_Pre_List[len(l:Prefix):-1] unlet g:FZF_Cmd_Completion_Pre_List - if len(l:Prefix) > 0 && ( - \ (l:Prefix[0] == 'e') || - \ (l:Prefix[0] == 'tabe') || - \ (l:Prefix[0] == 'vs') || - \ (l:Prefix[0] == 'sp') - \) - return join(l:Prefix + map(fzf#run({'options': '--select-1 --query='.l:cmdline_list[-1] }), - \'escape(v:val, " ")')) - elseif len(l:Prefix) > 0 && ( - \ (l:Prefix[0] == 'ar') || - \ (l:Prefix[0] == 'n') || - \ (l:Prefix[0] == 'sn') || - \ (l:Prefix[0] == 'arga') - \) - return join(l:Prefix + map(fzf#run({'options': '-m --select-1 --query='.l:cmdline_list[-1] }), - \'escape(v:val, " ")')) + if len(l:Prefix) > 0 && l:Prefix[0] =~ + \ '^ed\=i\=t\=$\|^spl\=i\=t\=$\|^tabed\=i\=t\=$\|^arged\=i\=t\=$\|^vsp\=l\=i\=t\=$' + "single-argument file commands + return CmdLineDirComplete(l:Prefix, "",l:cmdline_list[-1]) + elseif len(l:Prefix) > 0 && l:Prefix[0] =~ + \ '^arg\=s\=$\|^ne\=x\=t\=$\|^sne\=x\=t\=$\|^argad\=d\=$' + "multi-argument file commands + return CmdLineDirComplete(l:Prefix, '--multi', l:cmdline_list[-1]) else return join(l:Prefix + fzf#run({ \'source':l:FZF_Cmd_Completion_List, - \'options': '--select-1 --query='.l:cmdline_list[-1] - \})) + \'options': '--select-1 --query='.shellescape(l:cmdline_list[-1]) + \})) endif endfunction ``` -hit `` while in the ex commandline (i.e. after pressing `:`) to have fzf filter a list of vim's commandline auto-completions. Try `:colo␣` (be sure to include the space) or `:b␣`. There are special cases for handling file-searches, so that you can go deeper into the directory than just one layer, and so that you can add multiple files to the arglist at once. More special cases could be added. Some limitations: the auto-complete for `:help` and `:tag` are limited to 300 entries, so you may need to narrow it a bit. \ No newline at end of file +hit `` while in the ex commandline (i.e. after pressing `:`) to have fzf filter a list of vim's commandline auto-completions. Try `:colo␣` (be sure to include the space) or `:b␣`. There are special cases for handling file-searches, so that you can go deeper into the path than just one directory at a time, and so that you can add multiple files to the arglist at once. More special cases could be added. Some limitations: the auto-complete for `:help` and `:tag` are limited to 300 entries, so you may need to narrow it a bit. \ No newline at end of file