This is an old revision of the document!


Collection of Snippets for C

Longer, more elaborate Snippets are described in sub-pages list below. For simpler more concise Snippets, see the rest of this page.

PageDateUserTags
2011/05/25 21:05Matthew Brush,
2011/05/25 21:02Matthew Brush,

Structures

The following two snippets will insert a typedef struct when _ts<TAB> is pressed and a struct definition when _s<TAB> is pressed. Copy the two lines below into your snippets.conf file under the [C] group.

_ts=typedef struct\n{\n\t\n}\n%cursor%;
_s=struct %cursor%\n{\n\t\n};\n

The respective insertions are:

typedef struct
{
 
}
/* CursorGoesHere */;
struct /* CursorGoesHere */
{
 
};

The cursor will be placed where /* CursorGoesHere */ is (that text itself is not inserted).

Main function

This snippet inserts a main() function, by pressing _m<TAB>.

_m=int main(int argc, char *argv[])\n{\n\treturn 0;\n}\n

This snippet results in the insertion:

int main(int argc, char *argv[])
{
	/* CursorGoesHere */
	return 0;
}

The cursor will be placed where /* CursorGoesHere */ is (that text itself is not inserted).

Print/export