Sunday, September 15, 2019

Re: grab the output of command complete (C-D)

Am 13.09.2019 um 13:24 schrieb Renato Fabbri:
> I am almost sure I was able to do this...
>
> Example:
>
> :colo <C-D>
>
> shows the available colorschemes.
> If I want to have them in a variable,
>
> redir @a
> colo ^D
> redir END
>
> does not work, in any variation of colo ^D I tried
> (exe 'colo ^D', exe 'colo <C-D>', etc).
>
> Help?

Newer Vims (7.4.2011 or newer):
:echo getcompletion('', 'color')
=> ['blue', 'darkblue', 'default', 'delek', 'desert', ...]


Older Vims:
:echo ComplList('colo ')

func! ComplList(str)
" {str} partial command-line
let expansion = GetComplAll(a:str)
if a:str =~ '\s'
return split(strpart(expansion, matchend(a:str, '^.*\s')))
else
return split(expansion)
endif
endfunc

func! GetComplAll(str)
" {str} partial command-line
let d = {}
exec "sil norm! :". a:str. "\<C-A>\<C-\>e(extend(d,{'cmdl':getcmdline()}).cmdl)\n"
return get(d, 'cmdl', '')
endfunc

" Credits: ZyX

--
Andy

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/5D7E6841.0%40yahoo.de.

No comments:

Post a Comment