Search code examples
visual-studio-codevscode-extensionscode-snippets

How should I make my code snippets not distinguish between uppercase and lowercase letters


I am following this link(https://code.visualstudio.com/api/language-extensions/snippet-guide) to develop the code snippet function of my vscode exetension.

I want my code snippets not distinguish between uppercase and lowercase letters. For example, "Enum"/"ENUM"/"enum"/"eNum"/"eNUm"/...and so on is all I need, how should I configure my "prefix" field(like using regex?)?


Solution

  • You can define multiple prefixes, choose the ones that are the most likely

    {
      "Enum snip": {
        "prefix": ["enum", "ENUM", "Enum"],
        "body": ["MyEnum {}"],
        "description": "Enum foo bar."
      }
    }
    

    Or you can write a CompletionItemProvider and analyze the text before the cursor with a regex and create a snippet completion item.