sublime 键绑定从一个键绑定设置多个设置

sublime key binding to set multiple settings from one key binding

我正在使用 Sublime Text 3。

我可以使用此代码的键绑定更改字体:

[
    {
        "keys": ["ctrl+0"], "command": "global_set_setting",
        "args": {
            "setting": "font_face",
            "value": ""
        }
    },
    {
        "keys": ["ctrl+1"], "command": "global_set_setting",
        "args": {
            "setting": "font_face",
            "value": "Courier New"
        }
    },
]

但是,我也想同时更改配色方案。

我尝试过的:

[
    {
        "keys": ["ctrl+0"], "command": "global_set_setting",
        "args": {
            "setting": "font_size",
            "value": 10,
            "setting": "font_face",
            "value": "",
            "setting": "color_scheme",
            "value": "Monokai.sublime-color-scheme"
        }
    },
    {
        "keys": ["ctrl+1"], "command": "global_set_setting",
        "args": {
            "setting": "font_size",
            "value": 10,
            "setting": "font_face",
            "value": "Courier New",
            "setting": "color_scheme",
            "value": "Celeste.sublime-color-scheme"
        }
    },
]

当前结果:将应用的唯一更改是最后一个参数,它只是配色方案

预期结果:我想同时更改参数中的所有设置(使用一个热键)

是否可以使用键绑定来做到这一点?如果是,我该如何进行键绑定?

有一个名为 Preset Command 的 Sublime Text 插件可以完全满足您的需求。它在包控制上可用:Preset Command

它的工作原理是用户在 Presets.sublime-settings 文件中定义他们想要的设置组,必须为这些组命名。然后可以使用分配给一组设置的名称以通常的方式添加键绑定或调色板命令来调用插件。该插件有详细且写得很好的说明。

例如,您在问题中使用的设置设置需要以下步骤:

1) 使用 Package Control.

安装 Preset Command

2) 在文件中放置以下行:Path_To/sublime-text-3/Packages/User/Presets.sublime-settings

您可以通过以下方式轻松创建或打开它:Menu --> Preferences --> Package Settings --> Preset Command --> Manage Presets

{
    "presets":
    [
        {
            "name": "MonokaiSettingsPreset",
            "description": "Monokai, No Font Set, Size 10",
            "settings": {
                "Preferences.sublime-settings": {
                    "font_size": 10,
                    "font_face": "",
                    "color_scheme": "Monokai.sublime-color-scheme"
                }
            }
        },
        {
            "name": "CelesteSettingsPreset",
            "description": "Celeste, Courier New, Size 10",
            "settings": {
                "Preferences.sublime-settings": {
                    "font_size": 10,
                    "font_face": "Courier New",
                    "color_scheme": "Celeste.sublime-color-scheme"
                }
            }
        }
    ]
}

3) 在您的密钥文件中放置以下行,以及您要使用的任何密钥:Path_To/sublime-text-3/Packages/User/Default (Your OS).sublime-keymap

{ "keys": ["ctrl+k", "1"],
  "command": "preset_command_by_name",
  "args": { "name": "MonokaiSettingsPreset" } },

{ "keys": ["ctrl+k", "2"],
  "command": "preset_command_by_name",
  "args": { "name": "CelesteSettingsPreset" } },