I am wondering if it is possible to define a macro in Vim that will let you do the following. Suppose you have a class definition
class CRectangle {
int x;
int y;
_
};
where _ specifies the current cursor position.
Running the macro should automatically generate
class CRectangle {
int x;
int y;
public:
CRectangle (int x, int y);
~CRectangle ();
};
CRectangle::(int x, int y) {
this->x = x;
this->y = y;
}
I have been thinking about this for a while but didn't get anywhere. Perhaps creating the constructor definition is a bit too much to ask. Is it feasible to get at least the constructor declaration?
====
As sftrabbit points out, it is perhaps more desirable to generate something like
CRectangle::(int _x, int _y) : x(_x), y(_y) {}