【问题标题】:Add shortcut key for multiple plugins in Sublime Text 3在 Sublime Text 3 中添加多个插件的快捷键
【发布时间】:2014-05-19 14:06:36
【问题描述】:

我在 Sublime Text 3 中使用 CodeFormatter 和 SassBeautify 插件,以便为 .scss 文件和 .js/.html 文件提供语法高亮和格式化。我已经能够为任一插件设置快捷键,但不能同时使用这两个插件,具体取决于我所在的文件类型。

[{
    "keys": ["ctrl+alt+f"],
    "command": "sass_beautify"
}, {
    "keys": ["ctrl+alt+f"],
    "command": "code_formatter"
}]

有人可以建议怎么做吗?我试图理解“上下文”,但还不够好。

我做错了吗?我还有其他方法可以实现这一目标吗?

更正的键盘映射文件:

[{
    "keys": ["ctrl+alt+f"],
    "command": "sass_beautify",
    "context": [{
        "key": "selector",
        "operator": "equal",
        "operand": "source.scss"
    }]
}, {
    "keys": ["ctrl+alt+f"],
    "command": "code_formatter",
    "context": [{
        "key": "selector",
        "operator": "not_equal",
        "operand": "source.scss"
    }]
}]

【问题讨论】:

    标签: keyboard-shortcuts sublimetext3 code-formatting


    【解决方案1】:

    添加类似于以下内容的内容作为上下文条目

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

    { "key": "selector", "operator": "equal", "operand": "(text.html, source.js)", "match_all": true }

    操作数值是范围条目。有一个特定于平台的键绑定可以在状态栏中显示范围,但我不记得它们是什么。我个人使用https://github.com/facelessuser/ScopeHunter 来检查范围。

    【讨论】:

    • 谢谢。这非常有效(一旦我记得 context 属性需要一个数组)。
    猜你喜欢
    • 2020-02-03
    • 1970-01-01
    • 1970-01-01
    • 2014-11-23
    • 2013-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-27
    相关资源
    最近更新 更多