user2201723
user2201723

Reputation: 3

Do you understand this sublime snippet?

<snippet>
    <content><![CDATA[getElement${1/(T)|.*/(?1:s)/}By${1:T}${1/(T)|(I)|.*/(?1:agName)(?2:d)/}('$2')]]></content>
    <tabTrigger>get</tabTrigger>
    <scope>source.js</scope>
    <description>Get Elements</description>
</snippet>

I do not know this mean.I understand $1 ,but what is (?1:agName)(?2:d) ???

Upvotes: 0

Views: 95

Answers (1)

Bibhas Debnath
Bibhas Debnath

Reputation: 14939

The ones you pointed out are formatted strings for substitutions. They are part of the Sublime Text snippet substitutions, as documented -

In addition to the place holder syntax, tab stops can specify more complex operations with substitutions. Use substitutions to dynamically generate text based on a mirrored tab stop.

The substitution syntax has the following syntaxes:

${var_name/regex/format_string/}
${var_name/regex/format_string/options}

So in your snippet, these are the substitutions - ${1/(T)|.*/(?1:s)/}, ${1:T}, ${1/(T)|(I)|.*/(?1:agName)(?2:d)/}.

Upvotes: 1

Related Questions