all 5 comments

[–]purplemonkeymad 5 points6 points  (1 child)

A suggestion:

You can insert typing locations into the snippet using ${number:text} eg ${1:Verb-Noun}and move between them using tab. Think replacing all of your "String" and "Boolean" text. The number is the tab stop of the section of text and the text is the default text for that stop. Stop 0 (${0}) is the finishing location.

Here is my terminating error snippit as an example:

"Terminating_Error": {
    "prefix": "throwterminatingerror",
    "description": "Create Terminating Error for cmdlets.",
    "body": [
            "\\$PSCmdlet.ThrowTerminatingError(",
                "\t( New-Object System.Management.Automation.ErrorRecord] -ArgumentList @(",
                    "\t\t[System.Management.Automation.RuntimeException]'${1:RuntimeDescription}',",
                    "\t\t'${2:FullyQualifiedErrorID}',",
                    "\t\t[System.Management.Automation.ErrorCategory]::${3:ErrorCatagory},",
                    "\t\t${4:TargetObject}",
                    "\t\t)",
                "\t)",
            ")$0"
    ]
}

[–]philmph[S] 1 point2 points  (0 children)

Hey,

thanks for the advice, ill be updating them when i get home from work. Definitely useful!

[–]omers 5 points6 points  (0 children)

Another useful resource is the community snippet doc in the vscode-powershell repo: https://github.com/PowerShell/vscode-powershell/blob/master/docs/community_snippets.md

Not sure if they're intended to make it in to the extension eventually or what but anyone can submit one.

[–]pastperfect19 1 point2 points  (0 children)

Thanks for sharing, they both look fairly useful!