I want to create a custom function snippet like this :
const handle = () => {
}
But when I put it in visual studio code javascript snippets JSON file it gets red underline which means the format is not correct :
How can I put a custom function snippet with no error in visual studio code user snippets ?
You can't have newlines in JSON strings. Instead use \n
(or \r\n
on windows). But VS code expects you to pass different lines as different strings.
So, you can change your body to
[
"const handle = () => {",
"$0",
"}"
]
$0 is where your cursor will be if you accept the hint. The pressing tab will take you to $1, $2, $3, ....