Monday, April 4, 2011

Re: regarding completefunc

Thanks Christian. Got it. I tried with dictionary items, it is working great.  Thanks again.
Do you know any example or vim scripts for my reference. Or do we have any vim script, which will take a list of auto-completes and apply ( i mean like snippets).

Thanks
Venu



On Mon, Apr 4, 2011 at 5:48 PM, Christian Brabandt <cblists@256bit.org> wrote:
On Sun, April 3, 2011 5:36 am, venuparipelly wrote:
> Hi all,
> I would like to custom auto-complete function for my files. I can do
> something like this as provided in vimdoc.
>       fun! CompleteMonths(findstart, base)
>         if a:findstart
>           " locate the start of the word
>           let line = getline('.')
>           let start = col('.') - 1
>           while start > 0 && line[start - 1] =~ '\a'
>             let start -= 1
>           endwhile
>           return start
>         else
>           " find months matching with "a:base"
>           let res = []
>           for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec")
>             if m =~ '^' . a:base
>               call add(res, m)
>             endif
>           endfor
>           return res
>         endif
>       endfun
>       set completefunc=CompleteMonths
>
> But while showing in popup menu, i want different value to show. In
> above example, When I type Ja, It shoulde show January(2011) in popup,
> but when i select it should insert only Jan. Is there anyway to do
> this.
> Basically I want to show some more info to user, apart from auto-
> complete string. Please help with this... this is very usefull for my
> project.

See :h complete-items
You can use dictionary items that specify what kind of information is
shown and inserted. Additionally, you can also use a preview-window.


regards,
Christian

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

No comments: