Monday, April 4, 2011

Re: regarding completefunc

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

No comments: