I want to find the best way to toggle the Vintage package. That is, to turn it on and off using a keyboard shortcut.
My first pick was to use the plugin by Andrew Siegman:
# https://gist.github.com/blunket/e041565ef50b925ea68f29eb495e4433
import sublime
import sublime_plugin
class ToggleVintageCommand(sublime_plugin.TextCommand):
def run(self, edit):
settings = sublime.load_settings('Preferences.sublime-settings')
ignored = settings.get("ignored_packages")
if "Vintage" in ignored:
ignored.remove("Vintage")
else:
ignored.append("Vintage")
settings.set("ignored_packages", ignored)
But then I realized that some settings can be toggled without using any plugin. For example:
{ "keys": ["super+shift+w"], "command": "toggle_setting", "args": { "setting": "word_wrap" } },
I understand, of course, that this approach won’t allow me to remove "Vintage"
from "ignored_packages"
:
// This won't happen
FROM: "ignored_packages": ["Foo", "Vintage", "Bar"]
TO: "ignored_packages": ["Foo", "Bar"]
But maybe it will allow me, at least, to add/remove the
"ignored_packages": [],
line? Since I don’t use any other packages, this little trick will be enough for me.