To enhance your coding experience you can automatically switch between 'light' and 'dark' themes in Sublime Text 3. This reduces eye strain during extended coding sessions.
Fortunately, Sublime Text 3 makes it easy to automate this process. In this article, we'll see how to automatically change themes in Sublime Text 3 based on custom configuration.
Step 1: Install the 'Themes' Plugin
To begin, you'll need to install a plugin that allows you to switch between themes based on specific conditions. One such plugin is 'ThemeScheduler'.
You can install it through the Package Control manager in Sublime Text. Here's how:
- Open Sublime Text 3.
- open the command palette
- CTRL + Shift + P (Windows/Linux)
- CTRL + Shift + P (Mac)
- Open Package Control
- Type "Install Package Control" and select it to install the package manager if you haven't already.
- Type Install Package
- Search for 'ThemeScheduler' and select it to install.
Step 2: Configure the 'Themes' Plugin
After installing the 'ThemeScheduler' plugin, you need to configure it to change themes automatically.
Follow these steps:
- Go to 'Preferences' in the top menu.
- Choose 'Package Settings'
- then 'ThemeScheduler'
- Click on 'Settings - User'
- to open the user configuration file
Here's an example of how to configure the 'ThemeScheduler' plugin to automatically switch themes at specific times:
- to open the user configuration file
{
"enabled": true,
"themes":
[
{
"theme": "Packages/Dracula Color Scheme/Dracula.tmTheme",
"time": "20:00"
},
{
"theme": "Packages/GitHub Theme/schemes/GitHub Light.sublime-color-scheme",
"time": "8:30"
}
]
}
So you need to:
- enable the plugin by
"enabled": true
- select themes and time
Step 3: Theme Selection
Themes can be installed from the Package Control as shown in the previous step.
Once a theme is installed you can find it under the Sublime folder. Usually located at:
- Linux
~/.config/sublime-text-3/Packages
- OS X
~/Library/Application Support/Sublime Text 3/Packages
- Windows Regular Install
C:\Users\User\AppData\Roaming\Sublime Text 3\Packages
In my case - Linux Mint - I have themes:
- GitHub Theme
"Packages/GitHub Theme/schemes/GitHub Light.sublime-color-scheme"
- Dracula Color Scheme
"Packages/Dracula Color Scheme/Dracula.tmTheme"
The installed themes are located at: .config/sublime-text-3/Installed Packages
Sublime 4
For Sublime Text 4 there is feature which allows automatic theme change:
To enable auto theme switching in Sublime 4 do:
- Command Palette
- Select Color Scheme
- or Menu / Preferences / Select Color Scheme...
- In window UI: Select Color Scheme - search for "Auto"
- Select the "Auto" option
Some changes announce in Sublime 4
Added automatic dark/light theme and color scheme switching, based on OS theme changes
and
Theme can follow system dark mode preference and title bars can be themed on all platforms
Conclusion
Sublime Text 3 is a popular code editor known for its flexibility and extensive customization options.
We can change the theme based on custom configuration with ease.