sponsor Vim development Vim logo Vim Book Ad

cimpl : Generates implimentations for C/C++ function prototypes

 script karma  Rating 31/10, Downloaded by 1000  Comments, bugs, improvements  Vim wiki

created by
Alexander Rodin
 
script type
utility
 
description
This script generates empty implementations for C/C++ functions from specified header file. For following header file

#ifndef TEST_H
#define TEST_H
class Test
{
    public:
        explicit Test(int val = 0);
        int getVal() const
        {
            return m_val;
        }
        void setVal(int val);

        friend const Test operator +(const Test& a, const Test& b);

    private:
         int m_val;
};

const Test operator + ( const Test &a, const Test & b );
#endif

output will be

Test::Test(int val)
{
    
}

void Test::setVal(int val)
{
    
}

const Test operator +(const Test& a, const Test& b)
{
    
}
 
install details
You must have installed exuberant-ctags. Copy this script to ~/.vim/plugins. Also you can install tSkeleton (vimscript#1160) to add functions implementations in new source files.
This skeleton for .cpp files:

<+call:eval('findfile(expand("%:t:r").".h", ".;") != "" ? "\n#include \"".findfile(expand("%:r:t").".h", ".;")."\"\n" : ""')+><+call:eval('findfile(expand("%:t:r").".h", ".;") != "" ? "<+CURSOR+>".GenImpl(findfile(expand("%:r:t").".h", ".;")) : "\n<+CURSOR+>\n"')+>

will find .h files with same name in current directory and if it exists add implementations for definitions from header.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
cimpl.vim 0.03 2007-11-09 6.0 Alexander Rodin Add support for pure virtual functions (thanks to Anton)
cimpl.vim 0.02 2007-07-18 6.0 Alexander Rodin Add support for operators and friend functions
cimpl.vim 0.01 2007-07-17 6.0 Alexander Rodin Initial upload
ip used for rating: 18.216.251.37

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github