You can write an on_query_context
event listener and use your own settings. See the API docs for more information on this method. If you don't want to create your own on_query_context method, you can create a Preferences.sublime-settings
file in your package. The settings will be merged and applied to the view. Just be sure to note that to toggle the behavior, the users need to add an override in User/Preferences.sublime-settings.
Using package settings to enable/disable keybindings (as part of context list in keybindings)
-
23-06-2023 - |
Pregunta
is it possible to use settings defined in a package setting file as part of keybindings "context" argument? Below is an (abbreviated) example from the default keybindings files. This keybinding is only valid when the setting auto_indent
is true. auto_indent
is part of the main preferences. I have a my_package.sublime-settings
file in my package and would like to add keybindings that only work when a certain setting is true (let's say the use_keys
setting defined in my_package.sublime-settings
). How does that work? setting.use_keys
doesn't work and probably would be problematic because it overwrites default settings. setting.my_package.use_keys
doesn't work either. Any way to do this?
{ "keys": ["tab"], "command": "reindent", "context":
[
{ "key": "setting.auto_indent", "operator": "equal", "operand": true },
...
]
}
Solución
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow