首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何为sublimetext添加||的自动完成功能?

如何为sublimetext添加||的自动完成功能?
EN

Stack Overflow用户
提问于 2013-12-13 12:54:12
回答 2查看 217关注 0票数 0

如何为Ruby编辑的sublime text 2添加||的自动补全或换行?

是不是跟换行有关?

EN

回答 2

Stack Overflow用户

发布于 2013-12-13 23:02:53

打开Preferences -> Settings - User并添加以下内容:

代码语言:javascript
复制
"auto_complete_triggers":
[
    {
        "characters": "<",
        "selector": "text.html"
    },
    {
        "characters": "|",
        "selector": "source.ruby"
    },
    {
        "characters": ".",
        "selector": "source"
    }
]

这将在您打开标记时在HTML文档中触发自动完成,在Ruby文件中当您打开|foo bar|块参数时触发,以及在任何源代码中当您输入.访问方法、函数或属性时触发。

票数 0
EN

Stack Overflow用户

发布于 2013-12-14 04:39:21

找到我的答案了,只需使用自动配对括号的默认密钥绑定,并将括号更改为在用户密钥绑定中使用||,对于任何对如何自动配对||或在sublime text 2或3中添加任何自动配对感兴趣的人,请尝试以下操作:

代码语言:javascript
复制
// 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 }
    ]
},
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20559350

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档