你了解这个崇高的片段吗?

时间:2013-03-23 07:26:19

标签: sublimetext2

<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>

我不知道这是什么意思。我理解$1,但是什么是(?1:agName)(?2:d) ???

1 个答案:

答案 0 :(得分:1)

您指出的是用于替换的格式化字符串。它们是Sublime Text代码段替换的一部分,如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}

因此,在您的代码段中,这些是替换 - ${1/(T)|.*/(?1:s)/}${1:T}${1/(T)|(I)|.*/(?1:agName)(?2:d)/}