aboutsummaryrefslogtreecommitdiff
path: root/vim/bundle/vim-snippets/snippets/awk.snippets
blob: 32e56f2f490df4b6c39901ad90e5de2b3d658f19 (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
# cannot use /usr/bin/env because it does not support parameters (as -f)
snippet #! #!/usr/bin/awk -f
	#!/usr/bin/awk -f

# @include is a gawk extension
snippet inc @include
	@include "${1}"${0}

# @load is a gawk extension
snippet loa @load
	@load "${1}"${0}

snippet beg BEGIN { ... }
	BEGIN {
		${0}
	}

# BEGINFILE is a gawk extension
snippet begf BEGINFILE { ... }
	BEGINFILE {
		${0}
	}

snippet end END { ... }
	END {
		${0}
	}

# ENDFILE is a gawk extension
snippet endf ENDFILE { ... }
	ENDFILE {
		${0}
	}

snippet pri print
	print ${1:"${2}"}${0}

snippet printf printf
	printf("${1:%s}\n", ${2})${0}

snippet ign IGNORECASE
	IGNORECASE = ${1:1}

snippet if if {...}
	if (${1}) {
		${0}
	}

snippet ife if ... else ...
	if (${1}) {
		${2}
	} else {
		${0}
	}

snippet eif else if ...
	else if (${1}) {
		${0}
	}

snippet el else {...}
	else {
		${0}
	}

snippet wh while
	while (${1}) {
		${2}
	}

snippet do do ... while
	do {
		${0}
	} while (${1})

snippet for for
	for (${2:i} = 0; i < ${1:n}; ${3:++i}) {
		${0}
	}

snippet fore for each
	for (${1:i} in ${2:array}) {
		${0}
	}

# the switch is a gawk extension
snippet sw switch
	switch (${1}) {
	case ${2}:
		${3}
		break
	default:
		${0}
		break
	}

# the switch is a gawk extension
snippet case case
	case ${1}:
		${0}
		break