aboutsummaryrefslogtreecommitdiff
path: root/vim/bundle/vim-snippets/snippets/tcl.snippets
blob: 9da703ceb04a19652c62d7c3069ebd900983f11c (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
# #!/usr/bin/env tclsh
snippet #!
	#!/usr/bin/env tclsh

# Process
snippet pro
	proc ${1:function_name} {${2:args}} {
		${0}
	}
#xif
snippet xif
	${1:expr}? ${2:true} : ${0:false}
# Conditional
snippet if
	if {${1}} {
		${0}
	}
# Conditional if..else
snippet ife
	if {${1}} {
		${2}
	} else {
		${0:# else...}
	}
snippet eif
	elseif {${1}} {
		${0}
	}
# Conditional if..elsif..else
snippet ifee
	if {${1}} {
		${2}
	} elseif {${3}} {
		${4:# elsif...}
	} else {
		${0:# else...}
	}
# If catch then
snippet ifc
	if { [catch {${1:#do something...}} ${2:err}] } {
		${0:# handle failure...}
	}
# Catch
snippet catch
	catch {${1}} ${2:err} ${0:options}
# While Loop
snippet wh
	while {${1}} {
		${0}
	}
# For Loop
snippet for
	for {set ${2:var} 0} {$$2 < ${1:count}} {${3:incr} $2} {
		${0}
	}
# Foreach Loop
snippet fore
	foreach ${1:x} {${2:#list}} {
		${0}
	}
# after ms script...
snippet af
	after ${1:ms} ${0:#do something}
# after cancel id
snippet afc
	after cancel ${0:id or script}
# after idle
snippet afi
	after idle ${0:script}
# after info id
snippet afin
	after info ${0:id}
# Expr
snippet exp
	expr {${0:#expression here}}
# Switch
snippet sw
	switch ${1:var} {
		${3:pattern 1} {
			${0:#do something}
		}
		default {
			${2:#do something}
		}
	}
# Case
snippet ca
	${1:pattern} {
		${2:#do something}
	}
# Namespace eval
snippet ns
	namespace eval ${1:path} {${0:#script...}}
# Namespace current
snippet nsc
	namespace current