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
snippets:c:start [2011/05/25 21:32] codebrainzsnippets:c:start [2011/06/13 17:39] (current) – replace tag index list by nspages list enrico
Line 1: Line 1:
 ====== Collection of Snippets for C ====== ====== Collection of Snippets for C ======
  
-{{topic>snippet +c}}+Longer, more elaborate Snippets are described in sub-pages list below.  For simpler more concise Snippets, see the rest of this page.
  
-{{tag>snippet}}+<nspages -title -simplelist -exclude:start -textns="" -textpages=""> 
 + 
 +====== 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