Updated November 26, 2019
I’ve been using a dark theme in SSMS for some time now. For myself, I find it far easier to read light on dark, if you choose the right colors. I modeled our CSS here after the same type of scheme (using a heavily customized version of WP-GeSHi-Highlight).
Here is a code sample:
SELECT GETDATE(), N'hello'
FROM sys.all_columns AS c
LEFT OUTER JOIN sys.all_objects AS o
ON c.[object_id] = o.[object_id]
/* ORDER BY something */
ORDER BY c.name;
EXEC sys.sp_help;
And here is a screenshot of the same code in my local copy of SSMS (it looks lighter in a web page than it does on my screen, I promise):
The only real difference, which you may have spotted, is that WP-GeSHi treats ambiguous words like LEFT
and RIGHT
as if they were built-in functions (which they are), while SSMS treats them as keywords (which they also are).
There are two ways to go about this:
1. You can set the color settings manually
2. You can import my theme via a .vssettings file that I share below
Doing this the hard way
You can do this manually, of course. Go to Tools / Options / Environment / Fonts and Colors. Highlight text editor and make the background dark and the foreground light:
(Mine are RGB(228,228,228) for Item foreground and RGB(50,50,50) for Item background.)
Then go down the list and change the “Item foreground” color for things you want to change, using the Custom… button. Put a snippet of text in a query window that has just about everything – DMVs, functions, keywords, system procedures, comments, highlighted text, string, etc. so you can see the effects after every change.
You’ll have to play with it on your own to get the settings you like. Here are some of the other customizations I’ve made (the update is that I’ve chosen a slightly different pink for built-in functions, changed SQL stored procedures to green in order to match DMVs and system tables, and changed comments to orange):
- Comment: RGB(255,175,45)
- Keyword: RGB(127,176,228)
- Script Comment: RGB(255,175,45)
- Script keyword: Cyan RGB(0,255,255)
- Script string: Yellow RGB(255,255,0)
- SQL Operator: RGB(199,199,199)
- SQL Stored Procedure: RGB(128,255,128)
- SQL String: Yellow RGB(255,255,0)
- SQL System Function: RGB(220,120,255)
- SQL System Table: RGB(128,255,128)
I also make size changes for text results and grid results (which require a restart of the application to take effect), and I change grid results from MS Sans Serif to Calibri, and text results from Courier New to Consolas.
Doing this the smart way
A while back, Doug Holland blogged about using the VSSettings file to share themes. (In fact, you may like his color scheme better than mine.)
After the one-time manual process above, it was easy to share the .vssettings file so that I could implement the same color scheme on other machines.
First, I need to go to Tools, Import and Export Settings, and choose “Export selected environment settings:
Then I select only the checkbox for All Settings > Options > Environment > Fonts and Colors:
Note: I also use pretty big fonts in order to minimize the need to zoom anything when presenting. So I’ve created two separate files, one with LargeFonts
in the name, and one with NormalFonts
. You can download them here and start from whichever one is more appropriate for you:
To import them, you follow the wizard in almost the same way. Go to the same menu item, but this time choose Import selected environment settings. You will be prompted to save your current settings (a good idea; in the event you can’t stand my colors, it will be easy to revert):
Then you will likely have to move the above files into your Documents \ SQL Server Management Studio \ Settings \ SQL Server Management Studio folder to have them show up here:
Then the following options should be the only ones selected, and you can choose Finish:
Note that some settings may not take effect until you re-launch Management Studio (grid and text result settings are still sticky even in the most recent SQL Server 2016 version).
I keep these two files on a thumb drive and in the cloud so that, no matter where I am, it’s drop-dead simple to switch sensible coding font sizes to making all of my code and results readable to the nosebleed seats in a large room at a conference. I’m thinking about adding other options to my switch files too, like returning results in a separate tab, including the query output in the results, and other things I tend to do only when demoing / presenting.
Note: this should work for Visual Studio as well, but I haven’t tried it (and my specific customizations won’t affect most of what you do in VS anyway). Enjoy, and let me know if you have any suggestions or what additional customizations you have made.
Aaron (@AaronBertrand) is a Data Platform MVP with industry experience dating back to Classic ASP and SQL Server 6.5. He is editor-in-chief of the performance-related blog, SQLPerformance.com.
Aaron’s blog focuses on T-SQL bad habits and best practices, as well as coverage of updates and new features in Plan Explorer, SentryOne, and SQL Server.