Skip to content

Commit 370d5be

Browse files
jriekenDonJayamanne
authored andcommitted
Update snippets to use correct placeholder syntax (#976)
Many snippets here use the TM variable syntax instead of the placeholder/tabstop syntax. The snippet parser in VS Code has now become more strict any will interpret `${foo}` as variable, not as placeholder anymore. This PR updates many snippets to use the correct placeholder syntax, e.g `${1:foo}`. For reference see: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_snippet-syntax. Related to microsoft/vscode#26733
1 parent b2d6894 commit 370d5be

1 file changed

Lines changed: 52 additions & 52 deletions

File tree

snippets/python.json

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,70 +2,70 @@
22
"if": {
33
"prefix": "if",
44
"body": [
5-
"if ${expression}:",
6-
"\t${pass}"
5+
"if ${1:expression}:",
6+
"\t${2:pass}"
77
],
88
"description": "Code snippet for an if statement"
99
},
1010
"if/else": {
1111
"prefix": "if/else",
1212
"body": [
13-
"if ${condition}:",
14-
"\t${1:pass}",
13+
"if ${1:condition}:",
14+
"\t${2:pass}",
1515
"else:",
16-
"\t${2:pass}"
16+
"\t${3:pass}"
1717
],
1818
"description": "Code snippet for an if statement with else"
1919
},
2020
"elif": {
2121
"prefix": "elif",
2222
"body": [
23-
"elif ${expression}:",
24-
"\t${pass}"
23+
"elif ${1:expression}:",
24+
"\t${2:pass}"
2525
],
2626
"description": "Code snippet for an elif"
2727
},
2828
"else": {
2929
"prefix": "else",
3030
"body": [
3131
"else:",
32-
"\t${pass}"
32+
"\t${1:pass}"
3333
],
3434
"description": "Code snippet for an else"
3535
},
3636
"while": {
3737
"prefix": "while",
3838
"body": [
39-
"while ${expression}:",
40-
"\t${pass}"
39+
"while ${1:expression}:",
40+
"\t${2:pass}"
4141
],
4242
"description": "Code snippet for a while loop"
4343
},
4444
"while/else": {
4545
"prefix": "while/else",
4646
"body": [
47-
"while ${expression}:",
48-
"\t${1:pass}",
47+
"while ${1:expression}:",
48+
"\t${2:pass}",
4949
"else:",
50-
"\t${2:pass}"
50+
"\t${3:pass}"
5151
],
5252
"description": "Code snippet for a while loop with else"
5353
},
5454
"for": {
5555
"prefix": "for",
5656
"body": [
57-
"for ${target_list} in ${expression_list}:",
58-
"\t${pass}"
57+
"for ${1:target_list} in ${2:expression_list}:",
58+
"\t${3:pass}"
5959
],
6060
"description": "Code snippet for a for loop"
6161
},
6262
"for/else": {
6363
"prefix": "for/else",
6464
"body": [
65-
"for ${target_list} in ${expression_list}:",
66-
"\t${1:pass}",
65+
"for ${1:target_list} in ${2:expression_list}:",
66+
"\t${3:pass}",
6767
"else:",
68-
"\t${2:pass}"
68+
"\t${4:pass}"
6969
],
7070
"description": "Code snippet for a for loop with else"
7171
},
@@ -74,8 +74,8 @@
7474
"body": [
7575
"try:",
7676
"\t${1:pass}",
77-
"except ${expression} as ${identifier}:",
78-
"\t${2:pass}"
77+
"except ${2:expression} as ${3:identifier}:",
78+
"\t${4:pass}"
7979
],
8080
"description": "Code snippet for a try/except statement"
8181
},
@@ -94,10 +94,10 @@
9494
"body": [
9595
"try:",
9696
"\t${1:pass}",
97-
"except ${expression} as ${identifier}:",
98-
"\t${2:pass}",
97+
"except ${2:expression} as ${3:identifier}:",
98+
"\t${4:pass}",
9999
"else:",
100-
"\t${3:pass}"
100+
"\t${5:pass}"
101101
],
102102
"description": "Code snippet for a try/except/else statement"
103103
},
@@ -106,10 +106,10 @@
106106
"body": [
107107
"try:",
108108
"\t${1:pass}",
109-
"except ${expression} as ${identifier}:",
110-
"\t${2:pass}",
109+
"except ${2:expression} as ${3:identifier}:",
110+
"\t${4:pass}",
111111
"finally:",
112-
"\t${3:pass}"
112+
"\t${5:pass}"
113113
],
114114
"description": "Code snippet for a try/except/finally statement"
115115
},
@@ -118,76 +118,76 @@
118118
"body": [
119119
"try:",
120120
"\t${1:pass}",
121-
"except ${expression} as ${identifier}:",
122-
"\t${2:pass}",
121+
"except ${2:expression} as ${3:identifier}:",
122+
"\t${4:pass}",
123123
"else:",
124-
"\t${3:pass}",
124+
"\t${5:pass}",
125125
"finally:",
126-
"\t${4:pass}"
126+
"\t${6:pass}"
127127
],
128128
"description": "Code snippet for a try/except/else/finally statement"
129129
},
130130
"with": {
131131
"prefix": "with",
132132
"body": [
133-
"with ${expression} as ${target}:",
134-
"\t${pass}"
133+
"with ${1:expression} as ${2:target}:",
134+
"\t${3:pass}"
135135
],
136136
"description": "Code snippet for a with statement"
137137
},
138138
"def": {
139139
"prefix": "def",
140140
"body": [
141-
"def ${funcname}(${parameter_list}):",
142-
"\t${pass}"
141+
"def ${1:funcname}(${2:parameter_list}):",
142+
"\t${3:pass}"
143143
],
144144
"description": "Code snippet for a function definition"
145145
},
146146
"def(class method)": {
147147
"prefix": "def(class method)",
148148
"body": [
149-
"def ${funcname}(self, ${parameter_list}):",
150-
"\t${pass}"
149+
"def ${1:funcname}(self, ${2:parameter_list}):",
150+
"\t${3:pass}"
151151
],
152152
"description": "Code snippet for a class method"
153153
},
154154
"def(static class method)": {
155155
"prefix": "def(static class method)",
156156
"body": [
157157
"@staticmethod",
158-
"def ${funcname}(${parameter_list}):",
159-
"\t${pass}"
158+
"def ${1:funcname}(${2:parameter_list}):",
159+
"\t${3:pass}"
160160
],
161161
"description": "Code snippet for a static class method"
162162
},
163163
"def(abstract class method)": {
164164
"prefix": "def(abstract class method)",
165165
"body": [
166-
"def ${funcname}(self, ${parameter_list}):",
166+
"def ${1:funcname}(self, ${2:parameter_list}):",
167167
"\traise NotImplementedError"
168168
],
169169
"description": "Code snippet for an abstract class method"
170170
},
171171
"class": {
172172
"prefix": "class",
173173
"body": [
174-
"class ${classname}(${object}):",
175-
"\t${pass}"
174+
"class ${1:classname}(${2:object}):",
175+
"\t${3:pass}"
176176
],
177177
"description": "Code snippet for a class definition"
178178
},
179179
"lambda": {
180180
"prefix": "lambda",
181181
"body": [
182-
"lambda ${parameter_list}: ${expression}"
182+
"lambda ${1:parameter_list}: ${2:expression}"
183183
],
184184
"description": "Code snippet for a lambda statement"
185185
},
186186
"if(main)": {
187187
"prefix": "if(main)",
188188
"body": [
189189
"def main():",
190-
"\t${pass}",
190+
"\t${1:pass}",
191191
"",
192192
"if __name__ == '__main__':",
193193
"\tmain()"
@@ -197,34 +197,34 @@
197197
"async/def": {
198198
"prefix": "async/def",
199199
"body": [
200-
"async def ${funcname}(${parameter_list}):",
201-
"\t${pass}"
200+
"async def ${1:funcname}(${2:parameter_list}):",
201+
"\t${3:pass}"
202202
],
203203
"description": "Code snippet for a async statement"
204204
},
205205
"async/for": {
206206
"prefix": "async/for",
207207
"body": [
208-
"async for ${target} in ${iter}:",
209-
"\t${block}"
208+
"async for ${1:target} in ${2:iter}:",
209+
"\t${3:block}"
210210
],
211211
"description": "Code snippet for a async for statement"
212212
},
213213
"async/for/else": {
214214
"prefix": "async/for/else",
215215
"body": [
216-
"async for ${target} in ${iter}:",
217-
"\t${1:block}",
216+
"async for ${1:target} in ${2:iter}:",
217+
"\t${3:block}",
218218
"else:",
219-
"\t${2:block}"
219+
"\t${4:block}"
220220
],
221221
"description": "Code snippet for a async for statement with else"
222222
},
223223
"async/with": {
224224
"prefix": "async/with",
225225
"body": [
226-
"async with ${expr} in ${var}:",
227-
"\t${block}"
226+
"async with ${1:expr} in ${2:var}:",
227+
"\t${3:block}"
228228
],
229229
"description": "Code snippet for a async with statement"
230230
},

0 commit comments

Comments
 (0)