2013-02-09 57 views
1

這裏是我的片斷:vim和snipmate /片段:如何創建自定義行爲

# Get repository of a table: 
snippet repo 
    $$2 = $this->getRepository('${1:Bundle}:${2:TableName}') 
    ${3} 

當我使用它,這裏就是它可能生成:

$Person = $this->getRepository('MyBundle:Person') 
$Address = $this->getRepository('MyBundle:Address') 

我想第一個小寫字母,總是小寫字母,並給我類似的東西:

$person = $this->getRepository('MyBundle:Person') 
$address = $this->getRepository('MyBundle:Address') 
... 

。有沒有辦法與snipmate做到這一點?

回答

1

這不能用snipMate完成。我試圖實現這一點,但是(特別是當轉換改變了字符的數量時),對於當前的實現來說,這是不可能的。

這可能是遷移到the UltiSnips plugin這一現代化維護的替代方案(但需要Python支持)的最佳理由。在那裏,該功能被稱爲轉換,並使用${<tab stop no/regular expression/replacement/options}語法。您可以使用\L正則表達式原子來小寫替換。

+0

我正在尋找遞歸片段(snippet中的片段)。非常感謝這些信息。 – 2013-02-10 20:15:32