我正在使用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"
}
},
]
当前结果:唯一适用的更改是最后一个参数,该参数仅是配色方案
预期结果:我想同时更改参数中的所有设置(使用一个热键)
是否可以通过键绑定做到这一点?如果是,我该如何进行键绑定?
答案 0 :(得分:1)
有一个名为Preset Command
的Sublime Text插件可以完全满足您的需求。它可在软件包控制中使用:Preset Command
它由用户在Presets.sublime-settings
文件中定义所需的设置组来工作,必须为这些组指定名称。然后可以按通常的方式添加按键绑定或调色板命令,以使用分配给一组设置的名称来调用插件。该插件有详细且写得很好的说明。
例如,您在问题中使用的设置设置需要执行以下步骤:
1)使用Preset Command
安装Package Control
。
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" } },