I do a lot of c++ programming in vim and I was wondering if there are any plugins or snippets out there that can generate a source file depending on the contents of the header file.
I.E: test.h
class test {
public:
test();
};
and then going into the test.cpp file and typing "src" and expanding it (using some sort of snippet plugin like UltiSnips) it would look in the test.h file for the funcions and (in this case) make:
test::test() {
//code
}
I got this idea from Derek Wyatt's blog and he does this using XPTemplate so I thought it would be great to do the same in UltiSnips.
Use the xptemplate plugin.
Examples:
http://www.derekwyatt.org/wp-content/uploads/2009/08/my.cpp.xpt.vim
http://www.derekwyatt.org/vim/working-with-vim-and-cpp/cpp-snippets
lh-cpp offers a :GOTOIMPL function that analyses the prototype of a given function, and either jumps to the associated definition or generates it on-the-fly. [NB: it knows what to do with virtual, static, namespace/embedded classes, return type, modifiers, and so on (except templates yet)]
Regarding how to parse a header file and generate all associated functions, the exact same question has been asked on vim mailing list 2-3 weeks ago where another solution has been given (protodef, that you have read about).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With