0

I am using Visual Code Studio as my IDE, and wanted to write a simple snippet for printing:

printf("%d", );

the snippet:

 "Print": {
    "prefix": "printf",
    "body": [
        "printf("%d",$1);",
        "$2"
    ],
    "description": "print"
}

It is a JSON file, however it gives me an error with %d and doesnt treat %d as a string, I suppose. The error being: Expected commajson(514)

1 Answers1

2

You need to escape double-quotes that appear in strings with a backslash, otherwise it looks like you're ending and restarting the string:

 "Print": {
    "prefix": "printf",
    "body": [
        "printf(\"%d\",$1);",
        "$2"
    ],
    "description": "print"
}
dbush
  • 205,898
  • 23
  • 218
  • 273