I'm writing a snippet for VSCode. I mean to write a line with three fields:
name {nickName} jobTitle
The second field "nickName" may or may not exist: if it exists it has curly brackets, if it does not exist there are not even curly brackets.
I'm trying the following snippet:
"New Item": {
"scope": "markdown",
"prefix": "new-item",
"body": "${1:name} ${2:{${3:nickname}}} ${4:job title}",
"description": "Insert a new item"
}
The first brace is managed correctly: if I keep it I can modify the "nickName" field, but if I remove it the "nickName" field also disappears. The problem is that the second bracket, however, always remains outside the management of the snippet and must, if necessary, be deleted by hand.
How can I solve the problem?
Solved.
The solution is
(note the double backslash).