]> git.r.bdr.sh - rbdr/dotfiles/blame_incremental - vim/snippets/c.snippets
Turn off the blur
[rbdr/dotfiles] / vim / snippets / c.snippets
... / ...
CommitLineData
1# main()
2snippet main
3 int main(int argc, const char *argv[])
4 {
5 ${1}
6 return 0;
7 }
8snippet mainn
9 int main(void)
10 {
11 ${1}
12 return 0;
13 }
14# #include <...>
15snippet inc
16 #include <${1:stdio}.h>${2}
17# #include "..."
18snippet Inc
19 #include "${1:`Filename("$1.h")`}"${2}
20# #ifndef ... #define ... #endif
21snippet Def
22 #ifndef $1
23 #define ${1:SYMBOL} ${2:value}
24 #endif${3}
25snippet def
26 #define
27snippet ifdef
28 #ifdef ${1:FOO}
29 ${2:#define }
30 #endif
31snippet #if
32 #if ${1:FOO}
33 ${2}
34 #endif
35# Header Include-Guard
36snippet once
37 #ifndef ${1:`toupper(Filename('$1_H', 'UNTITLED_H'))`}
38
39 #define $1
40
41 ${2}
42
43 #endif /* end of include guard: $1 */
44# If Condition
45snippet if
46 if (${1:/* condition */}) {
47 ${2:/* code */}
48 }
49snippet el
50 else {
51 ${1}
52 }
53# Ternary conditional
54snippet t
55 ${1:/* condition */} ? ${2:a} : ${3:b}
56# Do While Loop
57snippet do
58 do {
59 ${2:/* code */}
60 } while (${1:/* condition */});
61# While Loop
62snippet wh
63 while (${1:/* condition */}) {
64 ${2:/* code */}
65 }
66# For Loop
67snippet for
68 for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
69 ${4:/* code */}
70 }
71# Custom For Loop
72snippet forr
73 for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
74 ${5:/* code */}
75 }
76# Function
77snippet fun
78 ${1:void} ${2:function_name}(${3})
79 {
80 ${4:/* code */}
81 }
82# Function Declaration
83snippet fund
84 ${1:void} ${2:function_name}(${3});${4}
85# Typedef
86snippet td
87 typedef ${1:int} ${2:MyCustomType};${3}
88# Struct
89snippet st
90 struct ${1:`Filename('$1_t', 'name')`} {
91 ${2:/* data */}
92 }${3: /* optional variable list */};${4}
93# Typedef struct
94snippet tds
95 typedef struct ${2:_$1 }{
96 ${3:/* data */}
97 } ${1:`Filename('$1_t', 'name')`};
98# Typdef enum
99snippet tde
100 typedef enum {
101 ${1:/* data */}
102 } ${2:foo};
103# printf
104# unfortunately version this isn't as nice as TextMates's, given the lack of a
105# dynamic `...`
106snippet pr
107 printf("${1:%s}\n"${2});${3}
108# fprintf (again, this isn't as nice as TextMate's version, but it works)
109snippet fpr
110 fprintf(${1:stderr}, "${2:%s}\n"${3});${4}
111# This is kind of convenient
112snippet .
113 [${1}]${2}