Search code examples
cvisual-studio-codecode-snippets

" symbol usage in user snippets of Visual Studio Code


I'm learning C programming language and as you know there is a command printf and it uses the "" symbol. I'm using Visual Studio Code for writing C. And I want add a snippet for printf. But when I tried adding these letters in JSON file of snippets and using these snippets,

"printf": {
        "prefix":"printf",
        "body": ["printf("$1"$2);"]
    }

it turns into this:

    printf(
);

How can I fix it?


Solution

  • Use the backslash character \ to escape the " quotes inside your snippet content string.

    "printf": {
        "prefix":"printf",
        "body": ["printf(\"$1\"$2);"]
    }