Is it possible to create a pick list from an internal array?
What I have in mind would be something like i_CTRL-P (word
completion). Only that the pick list would be initialized by
the array.
References to keywords would be a good starting point for research
if the feature is not yet implemented.
thanks
--
Tim
t...@johnsons-web.com
http://www.akwebsoft.com
On So, 03 Jan 2010, Tim Johnson wrote:
> Is it possible to create a pick list from an internal array?
> What I have in mind would be something like i_CTRL-P (word
> completion). Only that the pick list would be initialized by
> the array.
>
> References to keywords would be a good starting point for research
> if the feature is not yet implemented.
I would start reading at :h complete-functions.
If you specify in more details, what you want, we can probably figure
something out.
regards,
Christian
--
hundred-and-one symptoms of being an internet addict:
47. You are so familiar with the WWW that you find the search engines useless.
The key question really is how the OP would like to use the picked
value.
:help complete() has an example for how to use vim's own completion
menu to "pick an item from a list".
An alternative would be to use the popup menu (see :popup) what I have
sometimes used previously. But the handling of the picked item happens
asynchronously, which isn't always what you want.
Now I use (my own) tlib's tlib#input#List(), which allows you to do
something like:
" Single item selection
:echo tlib#input#List('s', 'Select one item', [100,200,300])
or
" Selection of mutliple items
:echo tlib#input#List('m', 'Select one or more item(s)',
[100,200,300])
There are other plugins that achieve similar goals slightly
differently (some of them make use of vim's completion menu, some
don't).
And if the list is short (let's say n < 20), then you could of course
use vim's own inputlist() function, e.g.: echo inputlist(range(20))
Cheers
"Tom Link" <mica...@gmail.com> wrote :
> > > Is it possible to create a pick list from an internal array?
> > If you specify in more details, what you want
> [...]
>
> There are other plugins that achieve similar goals slightly
> differently (some of them make use of vim's completion menu, some
> don't).
Indeed.
I have a few functions that help to define asynchronous pick lists. It is not really simple to use as there is a lot of things to specify: the list of items, and the title/question of course, but also the callback to execute, whether multi-selection is supported and so on.
In the past I gave a quick tour of the library: http://www.mail-archive.com/vim...@googlegroups.com/msg04606.html
HTH,
--
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/