如何小写Textmate片段输入的第一个字母?

时间:2016-01-13 13:48:39

标签: textmate textmatebundles textmate2

我有创建getter方法的快捷方式,现在这是我的代码段代码:

public function get${1:PropertyName}() {
    return \$this->${1:propertyName};
}
$0

输出我正在寻找:

public function getAreaCode() {
    return $this->areaCode;
}

所以问题是,如何自动将输入的第一个字母转换为小写,但仅限于第二行?

1 个答案:

答案 0 :(得分:1)

您可以执行与第一个字符匹配的正则表达式匹配,并将其修改为:

public function get${1/./\u/}() {
    return \$this->${1:propertyName};
}
$0

我已经使用了这个,还要添加属性并使用下拉列表设置范围:

${2|private,protected,public|} \$${1};

${3|public,protected,private|} function get${1/./\u$0/}() {
    return \$this->${1:propertyName};
}
${3} function set${1/./\u$0/}(\$value) {
    \$this->${1} = \$value;
    return \$this;
}
$0

Final result

请参阅Macromates上的转换部分了解更多信息。