Created
April 16, 2013 11:53
-
-
Save jasonlong/5395357 to your computer and use it in GitHub Desktop.
A simple way to toggle between dark and light themes in Sublime Text 2.
This file contains hidden or 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+1"], "command": "toggle_color_scheme", | |
"args": { | |
"light_color_scheme": "Packages/User/Espresso Soda.tmTheme", | |
"dark_color_scheme": "Packages/User/Monokai Soda.tmTheme", | |
"light_theme": "Soda Light.sublime-theme", | |
"dark_theme": "Soda Dark.sublime-theme" | |
} | |
} |
This file contains hidden or 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 file to ~/Library/Application Support/Sublime Text 2/Packages/User/ | |
import sublime, 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) | |
settings.set('theme', dark_theme) | |
else: | |
settings.set('color_scheme', light_scheme) | |
settings.set('theme', light_theme) | |
sublime.save_settings('Preferences.sublime-settings') |
A very handy small plugin indeed. Thanks!
FYI when using it in a SublimeText 2 project, only the files open after opening the project will be updated with the corresponding color_scheme
. I.e. this plugin doesn't update the color_scheme
for the files that were already open the last time the project was closed. That's because color_scheme
s are saved per view
in the .sublime-workspace
file when closing the project and this buffer specific settings have the highest weight in the settings hierarchy. See my fork for a quickfix.
Cheers.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!