2016-05-23 89 views
1

我在具有類似像語法的文件工作自動生成的文本:開始換行與崇高的文本3

name=... 
line=... 
line=... 
line=... 
... 

我想就這樣,當我目前的線路以「line =」開始,當我按下「Enter」時,它將移動到下一行並用「line =」自動填充它。有沒有辦法做到這一點與EventListener插件或可能的方式來做到這一點與片段?

回答

2

此鍵綁定將工作:

{ "key": "selector", "operator": "equal", "operand": "source.python", "match_all": true }, 

{ 
    "keys": [ "enter" ], 
    "command": "insert", 
    "args": { "characters": "\nline=" }, 
    "context": 
     [ 
      { "key": "preceding_text", "operator": "regex_contains", "operand": "^line=", "match_all": true }, 
      { "key": "following_text", "operator": "regex_match", "operand": "$",  "match_all": true }, 
     ] 
}, 

此外,還可以通過追加類似下面的一行到context陣列添加scope特異性背景

有關的更多信息,請參閱:Sublime Text > Unofficial Documentation > Key Bindings 0個參數。

+1

是的完美。我不知道鍵綁定可以有一個上下文。非常感謝! – SpyMachine