-
-
Save josemarcosrf/9b75a552846c64ecb44560ad2b5f246b to your computer and use it in GitHub Desktop.
A simple way to toggle between dark and light themes in Sublime Text 2, also for open files in the .workspace settings file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copy this to your keybindings (Preferences > Key Bindings - User) | |
// Change the keybinding, color schemes, and themes to your preferences | |
{ | |
"keys": ["ctrl+alt+n"], "command": "toggle_color_scheme", | |
"args": { | |
"light_color_scheme": "Packages/Materialize/schemes/Material Primer Light.tmTheme", | |
"dark_color_scheme": "Packages/Materialize/schemes/Material Firewatch.tmTheme", | |
"light_theme": "Material Primer Light.sublime-theme", | |
"dark_theme": "Material Firewatch.sublime-theme" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From https://gist.github.com/rbf/195acdfe8f51b65e5ecd | |
# Forked from https://gist.github.com/jasonlong/5395357 | |
# // Copy this to your keybindings (Preferences > Key Bindings - User) | |
# // Change the keybinding, color schemes, and themes to your preferences | |
# | |
# { | |
# "keys": ["ctrl+shift+s"], "command": "toggle_color_scheme", | |
# "args": { | |
# "light_color_scheme": "Packages/User/Soda Light - Espresso.tmTheme", | |
# "dark_color_scheme": "Packages/User/Soda Dark - Monokai.tmTheme", | |
# "light_theme": "Soda Light.sublime-theme", | |
# "dark_theme": "Soda Dark.sublime-theme" | |
# } | |
# } | |
# | |
# ======================================================================== | |
# | |
# Add this as a new pluggin: (Tools > Developer > New Plugin... ) | |
import sublime | |
import sublime_plugin | |
class ToggleColorSchemeCommand(sublime_plugin.TextCommand): | |
def run(self, edit, **args): | |
light_scheme = args["light_color_scheme"] | |
dark_scheme = args["dark_color_scheme"] | |
light_theme = args["light_theme"] | |
dark_theme = args["dark_theme"] | |
settings = sublime.load_settings("Preferences.sublime-settings") | |
current_scheme = settings.get("color_scheme") | |
if current_scheme == light_scheme: | |
settings.set("color_scheme", dark_scheme) | |
for view in sublime.active_window().views(): | |
view.settings().set("color_scheme", dark_scheme) | |
settings.set("theme", dark_theme) | |
else: | |
settings.set("color_scheme", light_scheme) | |
for view in sublime.active_window().views(): | |
view.settings().set("color_scheme", light_scheme) | |
settings.set("theme", light_theme) | |
sublime.save_settings("Preferences.sublime-settings") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment