3

I have configured the following TypeScript snippet in Visual Studio Code

"console.log": {
        "prefix": "cl",
        "body": [
            "console.log();"
        ],
        "description": "console.log()"
    }

It doesn't work however, because there is already a snippet defined for the cl (class). How can I overwrite that snippet with mine? I'd like to use cl, because I have other IDEs configured the same way and would prefer not change my convention.

1 Answer 1

2

When you type cl a list of all the possible expansions of the cl snippet is shown and your snippet is probably around the bottom of the list. In order to access the snippet at the top of the list you can added the following to your settings.json

// Place your settings in this file to overwrite the default settings
{
    "typescript.useCodeSnippetsOnMethodSuggest": true,
    "editor.snippetSuggestions": "top",
    "editor.tabCompletion": true
}

Here notice the editor.snippetSuggestions. This is the setting which defines the sorting of the autocomplete list which appears when you type your snippet's abbreviation. By default it is bottom which is why your snippet appears at the end of the list.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.