3

For example I want to reuse this transform like a variable in my snippet instead of write the transform again and again

${TM_FILENAME_BASE/(.*)$/${1:/pascalcase}/}
    "example": {
        "prefix": "example",
        "body": [
            "${TM_FILENAME_BASE/(.*)$/${1:/pascalcase}/} ${1:name1} = _${1};",
            "${TM_FILENAME_BASE/(.*)$/${1:/pascalcase}/} ${2:name2} = _${2};",
            "${TM_FILENAME_BASE/(.*)$/${1:/pascalcase}/} ${3:name3} = _${3};",
            //...
        ],
        "description": "example"
    },
  • :(, thanks can you check this please https://stackoverflow.com/questions/59963489/make-a-vscode-snippet-that-can-use-a-variable-number-of-arguments-and-use-variab – Basketball ICO Feb 04 '20 at 17:18

1 Answers1

3

You can repeat the same transform by assigning it to a placeholder and referencing that number, like this:

  "example": {
    "prefix": "example",
    "body": [
      "${4:${TM_FILENAME_BASE/(.*)$/${1:/pascalcase}/}} ${1:name1} = _${1};",
      "${4} ${2:name2} = _${2};",
      "${4} ${3:name3} = _${3};",
    ]
  }