Hi,
Hari Krishna Dara wrote:
> The help on complete() gives an example as a usage pattern which seems
> to be very useful, but it doesn't work. Here is a slightly modified
> example to avoid breaking the lines in email transmission:
>
> inoremap <expr> <F5> ListWeeks()
> func! ListWeeks()
> call complete(col('.'), ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'])
> return ''
> endfunc
>
> If you hit <F5>, Vim complains about the complete() as not allowed.
>
> Error detected while processing function ListWeeks:
> line 1:
> E523: Not allowed here
I don't know the reason for this restriction, but it is documented under
":help complete()":
| Set the matches for Insert mode completion.
| Can only be used in Insert mode. You need to use a mapping
| with CTRL-R = |i_CTRL-R|. It does not work after CTRL-O or
| with an expression mapping.
Regards,
Jürgen
--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)