Skip to content

Feature Request: Allow snippet json prefix to be an array to support multiple prefixes for the same snippet #42838

@TylerLeonhardt

Description

@TylerLeonhardt

We have several of the same snippets in our snippets json:

"Function-Advanced": {
        "prefix": "function-advanced",
        "body": [
            "function ${1:Verb-Noun} {",
            "\t[CmdletBinding()]",
            "\tparam (",
            "\t\t$0",
            "\t)",
            "\t",
            "\tbegin {",
            "\t}",
            "\t",
            "\tprocess {",
            "\t}",
            "\t",
            "\tend {",
            "\t}",
            "}"
        ],
        "description": "Script advanced function definition snippet"
    },
"Cmdlet": {
        "prefix": "cmdlet",
        "body": [
            "function ${1:Verb-Noun} {",
            "\t[CmdletBinding()]",
            "\tparam (",
            "\t\t$0",
            "\t)",
            "\t",
            "\tbegin {",
            "\t}",
            "\t",
            "\tprocess {",
            "\t}",
            "\t",
            "\tend {",
            "\t}",
            "}"
        ],
        "description": "Script cmdlet definition snippet"
    },

This could be avoided by supporting an array of prefixes like so:

"Cmdlet": {
        "prefix": ["function-advanced", "cmdlet"], // <--- here
        "body": [
            "function ${1:Verb-Noun} {",
            "\t[CmdletBinding()]",
            "\tparam (",
            "\t\t$0",
            "\t)",
            "\t",
            "\tbegin {",
            "\t}",
            "\t",
            "\tprocess {",
            "\t}",
            "\t",
            "\tend {",
            "\t}",
            "}"
        ],
        "description": "Script cmdlet definition snippet"
    }

It'd help slim down snippet json files and support snippets that might go by different names.

Metadata

Metadata

Assignees

Labels

feature-requestRequest for new features or functionalitygood first issueIssues identified as good for first-time contributorshelp wantedIssues identified as good community contribution opportunitiesrelease-notesRelease notes issuessnippetsverification-neededVerification of issue is requestedverifiedVerification succeeded

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions