Reputation:
I have a question about snippets and choices. I would like t0 use variables in choices. Is this possible?
"test": {
"body": ["${1|choice1,choice2,$TM_FILENAME_BASE|}"],
"desciption": "test",
"prefix": "test"
}
Has somebody a solution for me?
Upvotes: 0
Views: 365
Reputation: 182771
There is an issue filed on this: Support Snippet Variables in Snippet Enums.
Which is now a candidate for the Backlog list - so go and upvote the issue if you would like to see this implemented natively.
Upvotes: 0
Reputation: 11
Unfortunately, it is impossible to include variables in snippets. However, there is an alternative. My example:
"Now": {
"prefix": "NOW",
"body": "${CURRENT_HOUR}:${CURRENT_MINUTE}${1| TODAY, |}",
"description": "Now"
},
"Today's Date": {
"prefix": "TODAY",
"body": [
"$CURRENT_DAY_NAME_SHORT, $CURRENT_MONTH_NAME_SHORT $CURRENT_DATE, $CURRENT_YEAR"
],
"description": "Today's Date"
}
, by which you can expand the "TODAY" snippet by tab once more.
Upvotes: 1