toggle theme sublime text code example
Example: toggle theme sublime text
import sublime
import sublime_plugin
class ToggleColorSchemeCommand(sublime_plugin.TextCommand):
def run(self, edit, **args):
settings = sublime.load_settings("Preferences.sublime-settings")
light_theme = "Solarized Flat Light.sublime-theme"
dark_theme = "Material-Theme-Darker.sublime-theme"
dark_color_scheme = "Packages/Material Theme - Mod/Material-Theme-Darker.tmTheme"
light_color_scheme = "Packages/User/Color Highlighter/themes/Solarized Flat Light.tmTheme"
current_theme = settings.get("theme", light_theme)
if current_theme == light_theme:
settings.set("theme", dark_theme)
settings.set("color_scheme", dark_color_scheme)
else:
settings.set("theme", light_theme)
settings.set("color_scheme", light_color_scheme)
sublime.save_settings("Preferences.sublime-settings")