Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
snippets:c:start [2011/05/25 21:14] codebrainzsnippets:c:start [2011/06/13 17:07] – add c tag enrico
Line 1: Line 1:
-==== Snippets for the and C++ Programming Language ====+====== Collection of Snippets for C ======
  
-  * [[snippets:c:library_headers|Library Header files Snippet]]+Longer, more elaborate Snippets are described in sub-pages list below.  For simpler more concise Snippets, see the rest of this page. 
 + 
 +{{topic>snippet +c}} 
 + 
 +====== 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. 
 + 
 +<code> 
 +_ts=typedef struct\n{\n\t\n}\n%cursor%; 
 +_s=struct %cursor%\n{\n\t\n};\n 
 +</code> 
 + 
 +The respective insertions are: 
 +<code c
 +typedef struct 
 +
 +  
 +
 +/* CursorGoesHere */; 
 +</code> 
 +<code c> 
 +struct /* CursorGoesHere */ 
 +
 +  
 +}; 
 +</code> 
 + 
 +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>''
 + 
 +<code> 
 +_m=int main(int argc, char *argv[])\n{\n\treturn 0;\n}\n 
 +</code> 
 + 
 +This snippet results in the insertion: 
 + 
 +<code c> 
 +int main(int argc, char *argv[]
 +
 + /* CursorGoesHere */ 
 + return 0; 
 +
 +</code> 
 + 
 +The cursor will be placed where ''/* CursorGoesHere */'' is (that text itself is not inserted). 
 + 
 +{{tag>snippet c}}
Print/export