Visual Studio Code user snippets not working
I've enabled the default "log" snippet in VS Code. I also added another snippet. Neither show up when I type their prefixes. I have set editor.tabCompletion
to true.
Any idea why these don't work?
There are a couple of ways you can fix this problem. The problem is Intellisense is getting in the way or default putting your snippets at the bottom of the list.
First I played with the suggestion delay, but then I settled on having Intellisense put my snippets in the top of the list of suggestions with the snippetSuggestions
user preference:
{
"editor.tabCompletion": true,
"editor.snippetSuggestions": "top"
}
Sometimes the obvious that gets overlooked first. Upon starting VSCode and creating a new document (Ctrl + N) it may come as a surprise that the snippets do not work. Check in the bottom right hand corner of the VSCode editor as per default a 'Plain Text' file is presented. Change the file type to your favourite language with snippets.
This may overcome some unnecessary trouble shooting ;-)
If you are trying to insert PHP snippets, its worth noting the you must manually include the
<?php
before the snippets will start to work.
For react with typescript, I had to specifically add 'typescriptreact' to the scope.
"scope": "javascript, typescript, typescriptreact"