views:

428

answers:

2

Is there a way to get vim to paste a function's arguments after selecting it via omnifunc (or at least displaying it after selecting it, but not before)? Something like:

myObject.play(int time, std::string foo)

Maybe even allows you to tab through the arguments like what those snippets plugins allow you to do.

Is there such a plugin or feature? I think this is extremely useful.

BTW, omnifunc's preview option is very slow and will not show up after you select a function.

A: 

you could get the snippetsEMU plugin from the vim website then set up a custom snippet for that function like this:

:Snippet play myObject.play(int <{time}>, <{std::string}> <{foo}>)<{}>
This way all you have to do is type play and hit the tab key to have it expanded the curly braces will allow you to tab through the the args. Hope this is what you're looking for...

Thanks, but I have a huge codebase and it's unrealistic to keep on creating snippets for each function.
I know the feeling, it is dreadfully slow :-\
@emergence: it might be possible to use ctags (or something like it) on the codebase and then munge the output with some script to create the necessary snippets. But I have no experience how the snippetsEMU plugin would handle several thousands of these snippets, which I'd expect from a big code base ...
I found this http://newsgroups.derkeiler.com/Archive/Comp/comp.editors/2008-03/msg00072.html that might be able to help you out. Let me know. Cheers
+1  A: 

Try code_complete.

It uses ctags to complete a function signature and allows you to cycle through the arguments list. It can complete other stuff as well - standard header files, for()/switch() blocks etc.

Georgi Kirilov