How to have a default word in a vscode snippet (Python)
Question:
I’m new in vscode and I’m adding a snippet for my python.
my snippet is this
"for i in a range": {
"prefix": "for",
"body": [
"for i in range($1,$2):",
"t$3"
],
In the $3 I want to have a "pass" as default and when I tap "tab" for the third time I want to select the pass for me and I change it if I wanted to
Answers:
What you are looking for is called a placeholder
, see snippet placeholders.
So this code would work:
"for i in a range": {
"prefix": "for",
"body": [
"for i in range($1,$2):",
"t${3:my default text}"
]
}
All of my default text
will be seleced when you get to that tabstop, you can either overwrite it or tab again to complete the snippet.
I’m new in vscode and I’m adding a snippet for my python.
my snippet is this
"for i in a range": {
"prefix": "for",
"body": [
"for i in range($1,$2):",
"t$3"
],
In the $3 I want to have a "pass" as default and when I tap "tab" for the third time I want to select the pass for me and I change it if I wanted to
What you are looking for is called a placeholder
, see snippet placeholders.
So this code would work:
"for i in a range": {
"prefix": "for",
"body": [
"for i in range($1,$2):",
"t${3:my default text}"
]
}
All of my default text
will be seleced when you get to that tabstop, you can either overwrite it or tab again to complete the snippet.