antimatter
antimatter

Reputation: 75

VSCode: Tab completion/snippets not working in Javascript

Since VSCode doesn't seem to feature autocompletion for if, elseif, etc for javascript, php and maybe even more, I wanted to create myself snippets to get around that.
The snippet:

{
    "If": {
        "scope": "javascript,typescript,php",
        "prefix": "if",
        "body": [
            "if ( ${1:true} ) {",
            "\t${2:/// code}",
            "}"
        ],
        "description": "generic if statement"
    }
}

Tab completion in php works as expected in javascript however it doesn't work at all.
Why is that?

UPDATE:
I have already figured out that there are default snippets for "if" and "ifelse".
vscode build in if snippets

The very top one is my snippet.
The build-in ones I have hidden from IntelliSense, so that they are not in the way. But as I said, this is just working for php, not javascript.
Removing my snippet and unhiding the build-in ones just causes that no if-snippet works anymore, not even php. That is the reason why I assumed that vscode has no if-completion support in the first place.
No matter how I put it, it never works :shrug:

Upvotes: 0

Views: 176

Answers (1)

Opas6
Opas6

Reputation: 21

VSCode has default snippets for many languages. See the default ones by pressing:

Shift + Cmnd + P or Shift + Ctrl + P on PC and typing Insert Snippet

Seems like if is already reserved for one of those in JavaScript.

Upvotes: 1

Related Questions