如何为Ruby编辑的sublime text 2添加||的自动补全或换行?
是不是跟换行有关?
发布于 2013-12-13 23:02:53
打开Preferences -> Settings - User并添加以下内容:
"auto_complete_triggers":
[
{
"characters": "<",
"selector": "text.html"
},
{
"characters": "|",
"selector": "source.ruby"
},
{
"characters": ".",
"selector": "source"
}
]这将在您打开标记时在HTML文档中触发自动完成,在Ruby文件中当您打开|foo bar|块参数时触发,以及在任何源代码中当您输入.访问方法、函数或属性时触发。
发布于 2013-12-14 04:39:21
找到我的答案了,只需使用自动配对括号的默认密钥绑定,并将括号更改为在用户密钥绑定中使用||,对于任何对如何自动配对||或在sublime text 2或3中添加任何自动配对感兴趣的人,请尝试以下操作:
// Auto-pair block args
{ "keys": ["|"], "command": "insert_snippet", "args": {"contents": "|$0|"}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|;|\\}|$)", "match_all": true }
]
},
{ "keys": ["|"], "command": "insert_snippet", "args": {"contents": "|${0:$SELECTION}|"}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": false, "match_all": true }
]
},
{ "keys": ["|"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^\\|", "match_all": true }
]
},
{ "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Left Right.sublime-macro"}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "\\|$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^\\|", "match_all": true }
]
},https://stackoverflow.com/questions/20559350
复制相似问题