sublimetext - I can't get this to work: In Sublime Text (3), I am trying to alternate a setting's value using the same shortcut/keymap and contexts -
in sublime text 3, trying alternate setting's value using same shortcut, differing contexts. basically, want alternate draw_white_space
setting between 3 possible values: none
, selection
, , all
.
i change setting enough 3 separate shortcuts/keymaps. here code (working):
{ "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", } }
but, able press ["ctrl+e", "ctrl+w"]
, have alternate through each possible value. yes, visual studio shortcut i'm used to!
i created looks me should work, doesn't. @ least not how want to. here code (broken):
{ "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" } ] }
i have tested out contexts, know work. instance, can manually set all
in settings file, shortcut checks all
work first time only. nor others work after that.
another thing noticed settings file not change draw_white_space
value when shortcut work (including 3 separate shortcuts). assumed might default behavior - settings changes may per session - , fine. but, removed setting , still same behavior.
i changing file opened via preferences
| key bindings - user
menu, opened <sublime text>\data\packages\user\default (windows).sublime-keymap
file.
any ideas? doing wrong or missing something?
maybe not want, can behavior pretty simple plugin.
import sublime import sublime_plugin class cycledrawwhitespacecommand(sublime_plugin.textcommand): def run(self, edit): view = self.view white_space_type = view.settings().get("draw_white_space") if white_space_type == "all": view.settings().set("draw_white_space", "none") elif white_space_type == "none": view.settings().set("draw_white_space", "selection") else: view.settings().set("draw_white_space", "all")
after save plugin, bind key binding cycle_draw_white_space
Comments
Post a Comment