【问题标题】:How to lowercase first letter of Textmate snippet input?如何小写Textmate片段输入的第一个字母?
【发布时间】:2016-01-13 13:48:39
【问题描述】:

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

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

我正在寻找的输出:

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

那么问题来了,如何自动将输入的第一个字母转换为小写,但只在第二行?

【问题讨论】:

    标签: textmate textmatebundles textmate2


    【解决方案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
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-11
      相关资源
      最近更新 更多