2016-01-13 34 views
1

我有快捷方式創建getter方法,這裏是我的代碼片段現在:如何將Textmate片段輸入的首字母小寫?

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

輸出我在尋找:

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

所以現在的問題是,如何自動變換輸入的第一字母變成小寫,但只在第二行?

回答

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轉型部分獲得更多。

相關問題