is there a way to assign a keyboard shortcut to a specific color scheme in Sublime Text 2? In Emacs it's easy to define a function that toggles "night-mode" color scheme and assigns it to a keyboard shortcut, I was wondering if you can also do it in ST2.
Piotr
Try something like this, in your user key binding:
{
"keys": ["YOUR_SHORTCUT"],
"command": "set_setting",
"args":
{
"setting": "color_scheme",
"value": "Packages/Color Scheme - Default/Solarized (Light).tmTheme"
}
}
Of course, change Packages/Color Scheme - Default/Solarized (Light).tmTheme
to whatever theme you prefer.
If you want a toggle between two color schemes, you can create a plugin (Tools/New Plugin...
):
import sublime, sublime_plugin
class ToggleColorSchemeCommand(sublime_plugin.TextCommand):
def run(self, edit, **args):
scheme1 = args["color_scheme_1"]
scheme2 = args["color_scheme_2"]
current_scheme = self.view.settings().get("color_scheme")
new_scheme = scheme1 if current_scheme == scheme2 else scheme2
self.view.settings().set("color_scheme", new_scheme)
and save it in your Packages/User
directory.
Then add a key binding like this:
{
"keys": ["YOUR_TOGGLE_SHORCUT"], "command": "toggle_color_scheme",
"args":
{
"color_scheme_1": "Packages/Color Scheme - Default/Solarized (Light).tmTheme" ,
"color_scheme_2": "Packages/Color Scheme - Default/Solarized (Dark).tmTheme"
}
}
If you don't want to bother with editing config files you can install SchemeCycle.
Then cycle color schemes with F8 and Shift+F8. With 2 themes (Dark / Light) it acts as toggling.
If you prefer Command Palette check Norris's answer or try ColorSchemeSelector with : Select Color Scheme
command, it will not pollute your pallete as much as Schemr.
Visualization AKA screens:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With