在Sublime Text 3中,我嘗試使用同樣的捷徑,但有不同的背景。基本上,我想在其三個可能的值之間交替設置draw_white_space
:none
,selection
和all
。我無法得到這個工作:在Sublime Text(3)中,我試圖使用相同的快捷鍵/鍵盤映射和上下文來替換設置的值
我用三個獨立的快捷鍵/鍵盤映射很容易地更改設置。下面是代碼(工作):
{
"keys": ["ctrl+e", "ctrl+w"],
"command": "set_setting",
"args": {
"setting": "draw_white_space",
"value": "all",
}
},
{
"keys": ["ctrl+e", "ctrl+q"],
"command": "set_setting",
"args": {
"setting": "draw_white_space",
"value": "none",
}
},
{
"keys": ["ctrl+e", "ctrl+s"],
"command": "set_setting",
"args": {
"setting": "draw_white_space",
"value": "selection",
}
}
但是,我真的想是要能夠按["ctrl+e", "ctrl+w"]
,並將它通過交替每個可能值。是的,這是我習慣的Visual Studio快捷方式!
我創造了什麼看起來像它應該工作,但它沒有。至少不是我想要的。這裏是代碼(破):
{
"keys": ["ctrl+e", "ctrl+w"],
"command": "set_setting",
"args": {
"setting": "draw_white_space",
"value": "none",
},
"context": [
{ "key": "setting.draw_white_space",
"operator": "equal", "operand": "all" }
]
},
{
"keys": ["ctrl+e", "ctrl+w"],
"command": "set_setting",
"args": {
"setting": "draw_white_space",
"value": "selection",
},
"context": [
{ "key": "setting.draw_white_space",
"operator": "equal", "operand": "none" }
]
},
{
"keys": ["ctrl+e", "ctrl+w"],
"command": "set_setting",
"args": {
"setting": "draw_white_space",
"value": "all",
},
"context": [
{ "key": "setting.draw_white_space",
"operator": "equal", "operand": "selection" }
]
}
我測試了我的上下文,所以我知道他們的工作。例如,我可以在我的設置文件中手動設置all
,然後檢查all
的快捷方式將僅在第一次使用。它和其他人將在那之後工作。
我注意到的另一件事是我的設置文件不會更改draw_white_space
值,當快捷方式工作(包括三個單獨的快捷方式)。我認爲這可能是默認行爲 - 設置更改可能是每個會話 - 並沒有問題。但是,我完全刪除了該設置,並且它仍然是相同的行爲。
我正在更改通過Preferences
打開的文件| Key Bindings - User
菜單,其中打開<Sublime Text>\Data\Packages\User\Default (Windows).sublime-keymap
文件。
任何想法?我做錯了什麼或缺少什麼?
不知道爲什麼'{ 「關鍵」: 「setting.draw_white_space」, 「經營者」: 「NOT_EQUAL」, 「操作數」: 「all」}'總是'true'。 – Kabie