4

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"
    },
1

1 Answer 1

4

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};",
    ]
  }
Sign up to request clarification or add additional context in comments.

1 Comment

That is a very nice technique. I didn't know you could do that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.