aboutsummaryrefslogtreecommitdiff
path: root/vim/bundle/vim-snippets/UltiSnips/cs.snippets
blob: aca245e5267c7ec57e8640e303bf0a682ed5e2b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
#######################################################################
#                      C# Snippets for UltiSnips                      #
#######################################################################

priority -50

#########################
#  classes and structs  #
#########################

snippet namespace "namespace" b
namespace ${1:MyNamespace}
{
	${VISUAL}$0
}
endsnippet

snippet class "class" w
class ${1:MyClass}
{
	$0
}
endsnippet

snippet struct "struct" w
struct ${1:MyStruct}
{
	$0
}
endsnippet

snippet interface "interface" w
interface I${1:Interface}
{
	$0
}
endsnippet

snippet enum "enumeration" b
enum ${1:MyEnum} { ${2:Item} };
endsnippet


############
#  Main()  #
############

snippet sim "static int main" b
static int Main(string[] args)
{
	$0
}
endsnippet

snippet svm "static void main" b
static void Main(string[] args)
{
	$0
}
endsnippet


################
#  properties  #
################

snippet prop "Simple property declaration" b
public ${1:int} ${2:MyProperty} { get; set; }
endsnippet

snippet propfull "Full property declaration" b
private ${1:int} ${2:_myProperty};

public $1 ${3:MyProperty}
{
	get { return $2; }
	set { $2 = value; }
}
endsnippet

snippet propg "Property with a private setter" b
public ${1:int} ${2:MyProperty} { get; private set; }
endsnippet


############
#  blocks  #
############

snippet #if "#if #endif" b
#if ${1:DEBUG}
${VISUAL}$0
#endif
endsnippet

snippet #region "#region #endregion" b
#region ${1:Region}
${VISUAL}$0
#endregion
endsnippet


###########
#  loops  #
###########

snippet for "for loop" b
for (int ${1:i} = 0; $1 < ${2:10}; $1++)
{
	${VISUAL}$0
}
endsnippet

snippet forr "for loop (reverse)" b
for (int ${1:i} = ${2:10}; $1 >= 0; $1--)
{
	${VISUAL}$0
}
endsnippet

snippet foreach "foreach loop" b
foreach (${3:var} ${2:item} in ${1:items})
{
	${VISUAL}$0
}
endsnippet

snippet while "while loop" b
while (${1:true})
{
	${VISUAL}$0
}
endsnippet

snippet do "do loop" b
do
{
	${VISUAL}$0
} while (${1:true});
endsnippet


###############
#  branching  #
###############

snippet if "if statement" b
if ($1)
{
	${VISUAL}$0
}
endsnippet

snippet ife "if else statement" b
if ($1)
{
	${VISUAL}$0
}
else
{
}
endsnippet

snippet elif "else if" b
else if ($1)
{
	$0
}
endsnippet

snippet elseif "else if" b
else if ($1)
{
	$0
}
endsnippet

snippet ifnn "if not null" b
if ($1 != null)
{
	${VISUAL}$0
}
endsnippet

snippet switch "switch statement" b
switch (${1:statement})
{
	case ${2:value}:
		break;

	default:
		$0break;
}
endsnippet

snippet case "case" b
case ${1:value}:
	$2
	break;
endsnippet


##############
#  wrappers  #
##############

snippet using "using statement" b
using (${1:resource})
{
	${VISUAL}$0
}
endsnippet

snippet unchecked "unchecked block" b
unchecked
{
	${VISUAL}$0
}
endsnippet

snippet checked "checked block" b
checked
{
	${VISUAL}$0
}
endsnippet

snippet unsafe "unsafe" b
unsafe
{
	${VISUAL}$0
}
endsnippet


########################
#  exception handling  #
########################

snippet try "try catch block" b
try
{
	${VISUAL}$0
}
catch (${1:Exception} ${2:e})
{
	throw;
}
endsnippet

snippet tryf "try finally block" b
try
{
	${VISUAL}$0
}
finally
{
}
endsnippet

snippet throw "throw"
throw new ${1}Exception("${2}");
endsnippet


##########
#  LINQ  #
##########

snippet from "LINQ syntax" b
var ${1:seq} =
	from ${2:item1} in ${3:items1}
	join ${4:item2} in ${5:items2} on $2.${6:prop1} equals $4.${7:prop2}
	select ${8:$2.prop3}
	where ${9:clause}
endsnippet


############################
#  feedback and debugging  #
############################

snippet da "Debug.Assert" b
Debug.Assert(${1:true});
endsnippet

snippet cw "Console.WriteLine" b
Console.WriteLine("$1");
endsnippet

# as you first type comma-separated parameters on the right, {n} values appear in the format string
snippet cwp "Console.WriteLine with parameters" b
Console.WriteLine("${2:`!p
snip.rv = ' '.join(['{' + str(i) + '}' for i in range(t[1].count(','))])
`}"${1:, something});
endsnippet

snippet mbox "Message box" b
MessageBox.Show("${1:message}");
endsnippet


##################
#  full methods  #
##################

snippet equals "Equals method" b
public override bool Equals(object obj)
{
	if (obj == null || GetType() != obj.GetType())
	{
		return false;
	}
	$0
	return base.Equals(obj);
}
endsnippet


##############
#  comments  #
##############

snippet /// "XML comment" b
/// <summary>
/// $1
/// </summary>
endsnippet