aboutsummaryrefslogtreecommitdiff
path: root/vim/bundle/vim-snippets/snippets/d.snippets
blob: 216a4d8925ea9bcd1bc99480897adef0f5c7ef20 (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
329
330
331
332
333
334
335
336
337
338
### Import
snippet imp
	import 
snippet pimp
	public import
### My favorite modules
snippet io
	std.stdio
snippet traits
	std.traits
snippet conv
	std.conv
snippet arr
	std.array
snippet algo
	std.algorithm
snippet theusual
	import std.stdio, std.string, std.array;
	import std.traits, std.conv, std.algorithm;
	import std.math, std.regex;
### Control Structures
snippet for
	for(int ${1:i} = 0; $1 < ${2:count}; $1++) {
		${0}
	}
snippet fe
	foreach(${1:elem}; ${2:range}) {
		${0}
	}
snippet fei
	foreach(${1:i}, ${2:elem}; ${3:range}) {
		${0}	
	} 
snippet fer
	foreach_reverse(${1:elem}; ${2:range}) {
		${0}	
	} 
snippet feri
	foreach_reverse(${1:i}, ${2:elem}; ${3:range}) {
		${0}  
	}
snippet sce
	scope(exit) ${1:f.close();}
snippet scs
	scope(success) ${1}
snippet scf
	scope(failure) ${1}
snippet el
	else {
		${1}	
	}
snippet eif
	else if(${1}) {
		${0}
	}
snippet if
	if(${1}) {
		${0}
	}
snippet ife
	if(${1}) {
		${2}	
	} else {
		${3}	
	}
snippet ifee
	if(${1}) {
		${2}	
	} else if(${3}) {
		${4}
	} else {
		${5}
	}
snippet sw
	switch(${1}) {
		${0}
	}
snippet cs
	case ${1:0}:
		${2}
		break;
snippet def
	default:
		${0}
snippet fsw
	final switch(${1}) {
		${0}
	}
snippet try
	try {
		${1}
	} catch(${2:Exception} ${3:e}) {
		${4}
	}
snippet tcf
	try {
		${0}
	} catch(${1:Exception} ${2:e}) {
		${3}
	} finally {
		${4}
	}
snippet wh
	while(${1:cond}) {
		${0}
	}
snippet dowh
	do {
		${1}
	} while(${2});
snippet sif
	static if(${1:cond}) {
		${2}
	}
snippet sife
	static if(${1}) {
		${2}
	} else {
		${3}
	}
snippet sifee
	static if(${1}) {
		${2}
	} else static if(${3}) {
		${4}
	} else {
		${5}
	}
snippet seif
	else static if(${1}) {
		${2}
	} 
snippet ?
	(${1: a > b}) ? ${2:a} : ${3:b}; 
snippet with
	with(${1:exp}) {
		${2}
	} ${0}	
### Functions
snippet fun
	${1:auto} ${2:func}(${3:params}) {
		${0}
	}
snippet contr
	in {
		${1}
	} out {
		${2}
	} body {
		${0}
	}
snippet l
	(${1:x}) => ${2:x}${0:;}
snippet funl
	function (${1:int x}) => ${2}${3:;}
snippet del
	delegate (${1:int x}) => ${2}${3:;} 
### Templates
snippet temp 
	template ${1:`vim_snippets#Filename("$2", "untitled")`}(${2:T}) {
		${0}
	}
snippet tempif
	template ${1:`vim_snippets#Filename("$2", "untitled")`}(${2:T}) if(${3:isSomeString!}$2) {
		${0}	
	}
snippet opApply
	int opApply(Dg)(Dg dg) if(ParameterTypeTuble!Dg.length == 2) {
		${0}
	}
snippet psn
	pure @safe nothrow
snippet safe
	@safe
snippet trusted
	@trusted
snippet	system
	@system
### OOPs
snippet cl
	class${1:(T)} ${2:`vim_snippets#Filename("$3", "untitled")`} {
		${0}	
	}
snippet str
	struct${1:(T)} ${2:`vim_snippets#Filename("$3", "untitled")`} {
		${0}	
	}
snippet uni
	union${1:(T)} ${2:`vim_snippets#Filename("$3", "untitled")`} {
		${0}	
	}
snippet inter
	interface I${1:`vim_snippets#Filename("$2", "untitled")`} {
		${0}
	}
snippet enum
	enum ${1} {
		${0}
	}
snippet pu
	public
snippet pr
	private
snippet po
	protected
snippet ctor
	this(${1}) {
		${0}
	} 
snippet dtor
	~this(${1}) {
		${0}
	}
### Type Witchery
snippet al
	alias ${1:b} = ${2:a};
	${0}
snippet alth
	alias ${1:value} this;
	${0}
### The Commonplace
snippet main
	void main() {
		${0}
	}
snippet maina
	void main(string[] args) {
		${0}
	}
snippet mod
	module ${1:main};${0}
snippet var
	${1:auto} ${2:var} = ${0:1};
snippet new
	${1:auto} ${2:var} = new ${3:Object}(${4});
	${0}
snippet file
	auto ${1:f} = File(${2:"useful_info.xml"}, ${3:"rw"});
	${0}
snippet map
	map!(${1:f})(${2:xs});
	${0}
snippet filter
	filter!(${1:p})(${2:xs});
	${0}
snippet reduce
	reduce!(${1:f})(${2:xs});
	${0}
snippet find
	find!(${1:p})($2:xs);
	${0}
snippet aa
	${1:int}[${2:string}] ${3:dict} = ${0};
### Misc
snippet #!
	#!/usr/bin/env rdmd
snippet bang
	#!/usr/bin/env rdmd
snippet rdmd
	#!/usr/bin/env rdmd
snippet isstr
	isSomeString!${1:S}
snippet isnum
	isNumeric!${1:N}
snippet tos
	to!string(${1:x});
	${0}
snippet toi
	to!int(${1:str});
	${0}
snippet tod
	to!double(${1:str});
	${0}
snippet un
	unittest {
		${0}
	}
snippet ver
	version(${1:Posix}) {
		${0}
	}
snippet de
	debug {
		${0}
	}
snippet sst
	shared static this(${1}) {
		${0}
	}
snippet td
	// Typedef is deprecated. Use alias instead.
	typedef
snippet ino
	inout
snippet imm
	immutable
snippet fin
	final
snippet con
	const
snippet psi
	private static immutable ${1:int} ${2:Constant} = ${3:1};
	${0}
snippet prag
	pragma(${1})
snippet pms
	pragma(msg, ${1:Warning});
snippet asm
	asm {
		${1}
	}
snippet mixin
	mixin(${1:`writeln("Hello, World!");`});
snippet over
	override
snippet ret
	return ${1};
snippet FILE
	__FILE__
snippet MOD
	__MODULE__
snippet LINE
	__LINE__
snippet FUN
	__FUNCTION__
snippet PF
	__PRETTY_FUNCTION__
snippet cast
	cast(${1:T})(${2:val});
snippet /*
	/*
	 * ${1}
	*/
### Fun stuff
snippet idk
	// I don't know how this works. Don't touch it.
snippet idfk
	// Don't FUCKING touch this.