Skip to content

Instantly share code, notes, and snippets.

@KevinJMao
Last active March 22, 2016 23:22
Show Gist options
  • Select an option

  • Save KevinJMao/bd2af61413b3e0904862 to your computer and use it in GitHub Desktop.

Select an option

Save KevinJMao/bd2af61413b3e0904862 to your computer and use it in GitHub Desktop.
Sublime Text 2/3 plugin snippet for toggling between two different Themes and Color Schemes
import sublime, sublime_plugin
class ToggleThemeAndSchemeCommand(sublime_plugin.TextCommand):
def run(self, edit, **args):
s = sublime.load_settings("Preferences.sublime-settings")
scheme1 = args["color_scheme_1"]
theme1 = args["theme_1"]
scheme2 = args["color_scheme_2"]
theme2 = args["theme_2"]
current_scheme = s.get("color_scheme", scheme1)
current_theme = s.get("theme", theme1)
new_scheme = scheme2
new_theme = theme2
if current_theme == theme1:
new_scheme = scheme2
new_theme = theme2
else:
new_scheme = scheme1
new_theme = theme1
s.set("color_scheme", new_scheme)
s.set("theme", new_theme)
sublime.save_settings("Preferences.sublime-settings")
@KevinJMao
Copy link
Author

Corresponding Sublime Text keymap entry: toggle_theme_and_scheme_keymap_entry.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment