Monday, January 4, 2010

Re: How to Create a pick (select) list

> > Is it possible to create a pick list from an internal array?
>
> If you specify in more details, what you want

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).

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments: