Search code examples
javascriptvisual-studio-codeeslintcode-snippetsvscode-snippets

How do I insert tabulation inside VS Code snippet?


I have a code snippet in VS Code, looks like this

"JS arrow function": {
    "scope": "javascript, typescript",
    "prefix": "af",
    "body": [
        "const ${1:name} = (${2:props}) => {",
        "   $3",
        "}"
    ],
    "description": "Create arrow function"
}

I want to have tabulation before the $3 tab stop, but VS Code shows an error :

Invalid characters in string. Control characters must be escaped.

At the same time putting 4 spaces before $3 works just fine, but I need tabulation exactly for my eslint config.

Is there a way to put tabulation there?


Solution

  • \t

    That is the tab character escaped.

    "JS arrow function": {
        "scope": "javascript, typescript",
        "prefix": "af",
        "body": [
            "const ${1:name} = (${2:props}) => {",
            "\t$3",
            "}"
        ],
        "description": "Create arrow function"
    }