regarding completefunc

60 views
Skip to first unread message

venuparipelly

unread,
Apr 2, 2011, 11:36:07 PM4/2/11
to vim_use
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.



Christian Brabandt

unread,
Apr 4, 2011, 8:18:51 AM4/4/11
to vim...@googlegroups.com

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

Venu Gopal

unread,
Apr 4, 2011, 8:23:33 AM4/4/11
to vim...@googlegroups.com
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




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

Reply all
Reply to author
Forward
0 new messages