Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can use the ${} notation to insert the variable name directly next to the plain text. For example, instead of using "${1:variable} " (with a space at the end), you can use "${1:variable}" (with no space) to eliminate the whitespace. Here's an example:

{
    "Print": {
        "prefix": "print",
        "body": [
            "console.log('${1:message}: ${2}'${3:, variable})"
        ],
        "description": "Print message with optional variable"
    }
}

This snippet allows you to print a message with an optional variable. If you don't include a variable, there will be no space between the colon and the closing quote. If you do include a variable, it will be immediately adjacent to the closing quote.