#Derive VS Code Snippets from Get-Command / Get-Help

13 messages · Page 1 of 1 (latest)

subtle blade
#

playing around with a little idea:
easy generation of VS Code Snippet extensions using the knowledge that allready is "out there" (in PowerShell)

thats what i came up with (s. attachments)

atm im struggling to somehow get the syntax parsed ... to add a little more use
does someone have a good idea how to get the syntax parsed to a "proper" snippet body - inkl. tabstops / options on variables where they make sense

exotic flower
subtle blade
#

its a different approach - if i summarize right: what martin does is to include the snippets in his ps module

#

allready got the params covered - just need to go down for different parametersets

subtle blade
light flare
#

for pwsh, for a $ literal I believe you need \\$ to prevent TM from using it
I didn't read them all, maybe you are using these already
You can make multilple choices, not just ${1:default value}

        "prefix": "choice",
        "description": "select from UI Popup menu",
        "body": [
            "${1|one,two, three|}"
        ]

TM_SELECTED_TEXT is useful

        "description": "[List<T>] multiLine",
        "scope": "powershell,ps1,md,markdown",
        "prefix": "list [List<T>] 🐒 multiLine",
        "body": [
            "[Collections.Generic.List[Object]]\\$${1:Items} = @(",
            "",
            "    ${2:${TM_SELECTED_TEXT}}",
            "",
            ")",
        ]
        // ---- 
        "prefix": "Escape Double Quotes",
        "description": "Transforms \" ⇒ \\\" mostly for JSON",
        "body": [
            "${TM_SELECTED_TEXT/[\"]/\\\"/gi}"
        ]
#

I used to have one that replaces selected text of \ with / , but I am having trouble recreating the regex

#

it's not quite working

"body": [
    "${TM_SELECTED_TEXT/(\\\\{2})/\\//gi}", 
]
#

I don't understand the noun part

subtle blade