Sublime Forum

Is there a way to switch between your installed themes?

#1

This seems like a very hidden feature if it exists? I seem to be able to change the colour scheme, but, can’t seem to switch between the “themes”.

Talking specifically about this config param:

Say you go Preferences > Browse packages

How am I meant to work out the exact name that needs to go in this option from these file names?

I hope there is a way.

Thanks,

1 Like

#2

There is no built in way, that would be the same for all themes.

one way would be to install PackageResourceViewer and use that to browse the contents of the packages - it is better than using Preferences -> Browse Packages because most packages are bundled in a .sublime-package (zip) file that you would have to find and explore manually.

If the theme is any good, it should add itself to a menu or the Command Palette, where you would be able to see and choose which of the theme files to use.

Looks like Material Theme has something in Command Palette:

https://github.com/equinusocio/material-theme/blob/develop/Default.sublime-commands

and Preferences -> Package Settings menu:

https://github.com/equinusocio/material-theme/blob/develop/Main.sublime-menu

0 Likes

#3

There’s also https://github.com/benweier/Themr, which states:

Themr allows you to quickly and easily cycle forward, backward, or randomly through your available UI themes using the command palette or keyboard shortcuts.

0 Likes

#4

This doesn’t solve your problem of having to type in the theme name (and I agree, it’s often confusing to figure out what it needs to be exactly), but just wanted to link to another theme switcher:

I’ve used it for a long while, mostly to just switch quickly between a dark -> light theme/color scheme if I happen to be coding in a bright area. Once you get the names figured out, you can quickly switch w/ command palette.

1 Like

#5

Then there is ColorSublime. I don’t use it.
I just want to mention it as a possible solution to the problem.

0 Likes

#6

ColorSublime has to do with color schemes rather than UI themes, if I’m not mistaken.

0 Likes

#7

I’ve just moved the following commands from my sublimefiles to my polyfill package which is available from Package Control.

  • Enable Theme
  • Enable Color Scheme

The color scheme includes a preview, I opted against a preview for themes because Sublime doesn’t handle that very well. The color scheme preview is fast, and the commands are as simple as possible, no bloat, no nonsense. They can be added as custom commands if you don’t want to install a package.

Also, with polyfill, you can navigate the overlay with ctr+j and ctrl+k. Try it when previewing color schemes.

Enable Theme

User/Default.sublime-commands:

{
    {
        "caption": "Application: Enable Theme",
        "command": "enable_theme"
    }
}

User/enable_theme.py

import sublime
import sublime_plugin
import os

class EnableThemeCommand(sublime_plugin.ApplicationCommand):

    def run(self):
        self.themes = []

        for theme in sublime.find_resources('*.sublime-theme'):
            if "Addon" not in theme:
                self.themes.append(os.path.basename(theme))

        if len(self.themes) > 0:
            sublime.active_window().show_quick_panel(self.themes, self.on_done)

    def on_done(self, index):
        if index == -1:
            return

        theme = self.themes[index]

        settings = sublime.load_settings('Preferences.sublime-settings')
        settings.set('theme', theme)
        sublime.save_settings('Preferences.sublime-settings')

Enable color Scheme

Includes preview!

User/Default.sublime-commands:

{
    {
        "caption": "Application: Enabe Color Scheme",
        "command": "enable_color_scheme"
    }
}

User/enable_color_scheme.py

import sublime
import sublime_plugin
import os

class EnableColorSchemeCommand(sublime_plugin.ApplicationCommand):

    def run(self):
        self.color_schemes = []

        for color_scheme in sublime.find_resources('*.tmTheme'):
            if "(SL)" not in color_scheme:
                self.color_schemes.append(color_scheme)

        if len(self.color_schemes) > 1:

            color_scheme = sublime.load_settings('Preferences.sublime-settings').get('color_scheme')

            if color_scheme not in self.color_schemes:
                self.color_schemes.insert(0, color_scheme)

            self.window = sublime.active_window()
            self.window.show_quick_panel(
                self.color_schemes,
                self.on_done,
                0,
                self.color_schemes.index(color_scheme),
                self.on_select
            )

    def on_select(self, index):
        if index == -1:
            return

        color_scheme = self.color_schemes[index]

        for group in range(0, self.window.num_groups()):
            active_view_in_group = self.window.active_view_in_group(group)
            if active_view_in_group:
                active_view_in_group.settings().set('color_scheme', color_scheme)

    def on_done(self, index):
        for view in self.window.views():
            view.settings().erase('color_scheme')

        if index == -1:
            return

        color_scheme = self.color_schemes[index]

        settings = sublime.load_settings('Preferences.sublime-settings')
        settings.set('color_scheme', color_scheme)
        sublime.save_settings('Preferences.sublime-settings')
0 Likes

#8

You are mistaken:
From the instructions for the ColorSublime package:

Usage

Press ctl+shift+p (Windows/Linux) or ⇧+⌘+p (OSX) to open up Sublime Text's command menu
Select Colorsublime: Install Theme
Use the arrow keys to run through the themes and see your current tab change in realtime!
0 Likes

#9

I did read that, but to me it seems quite clear that the term “theme” is being misused – they mean to say “scheme”, as that’s what the plugin is actually changing.

In any case, it still seems useful.

0 Likes

#10

it’s unfortunate that ST uses TextMate’s poorly named tmTheme file extension for color schemes, so it’s easy to see how people can misuse the terms.

1 Like

#11

If you only want to have another main menu entry to switch themes you may look for Themes Menu Switcher in Package control or here:

https://packagecontrol.io/packages/Themes%20Menu%20Switcher

With the Skins package you can save any compination of visual settings (theme and color scheme) and recall it later easily with Ctrl+F12 key. It also supports *.skins files which may be included into any theme package.

https://packagecontrol.io/packages/Skins

1 Like