Code on the Rocks
Code on the Rocks

Reputation: 17764

Can you add a comma to a VS Code Snippet placeholder option?

I want to create a VS Code snippet that uses the choices feature:

"Fool's Dart Types": {
        "scope": "dart",
        "prefix": "foolsTypes",
        "body": [
            "${1|bool,String,int,double,num,List<Map<String, dynamic>>,Map<String, dynamic>,dynamic|} ${2:variableName};"
        ]
    },

The issue is that the commas inside my List and Map choices break up the choices so they look like this:

Snippet choices

I tried using the \ character but that doesn't work inside the choices brackets.

Upvotes: 0

Views: 21

Answers (1)

Code on the Rocks
Code on the Rocks

Reputation: 17764

I was using the \ wrong. You have to use 2 backslashes to escape the characters so doing this works:

"Fool's Dart Types": {
        "scope": "dart",
        "prefix": "foolsTypes",
        "body": [
            "${1|bool,String,int,double,num,List<Map<String\\, dynamic>>,Map<String\\, dynamic>,dynamic|} ${2:variableName};"
        ]
    },

Upvotes: 0

Related Questions