How To Add Awesome Monokai Colors For Beautiful C# Development in Visual Studio 2017 For Windows

You’ve finally come to the right place! It IS Possible!

Image for post
Image for post

^ How a part of a SHA-3 implementation in C# looks in Visual Studio after following this tutorial.

Ah… finally! If you’ve spent a while trying to find how to get Monokai syntax highlighting in Visual Studio 2017, you’ve come to the right place!

This took me a few days to figure out, and with no step-by-step tutorial to be found (partially WHY it took me a few days to figure out), I made this in-depth how-to for all you Monokai lovers out there.

***Update January 10th, 2019: To save a BUNCH of time, you can get the vssettings corresponding to this tutorial at this repository!

***Note that this tutorial is NOT for Visual Studio CODE, the editor! This tutorial is for Visual Studio, the IDE.

***Also note that this tutorial is for Windows. In the Xamarin version for Mac, Monokai is a built-in in the menu Visual Studio Community (the version I have 😃) →Preferences… →Text Editor →Color Theme →Monokai →OK:

(I also set my theme to ‘Dark’ on my Mac, under the menu Visual Studio Community →Preferences… →Visual Style →Dark)

Background: I ❤️ Monokai

NOT Monokai ‘Dark’, NOT Panda, NOT Sublime Material! Argh! This is all the stuff I ran into while trying to add Monokai-like syntax highlighting.

We’re gonna implement pure original Monokai syntax highlighting sweetness, with the colors as used in Ace Editor:

I may be a bit obsessive about this, but with any new editor, I always feel the need to add the Monokai syntax highlighting. This has been the case ever since I used good ol’ Sublime text. It sounds corny, but to me, programming never feels quite right with Monokai. Heck, I even themed my blog with monokai colors!

(See this GitHub repository as an example of my obsession. I wrote a Greasemonkey Script that changes the Ace Editor used in SAP’s Web IDE after loading to Monokai.)

So, let’s get started. This miraculously worked out to be a typical 1–2–3 step process!

Step 1: Set Visual Studio Color Theme to ‘Dark’

This is more of a prerequisite than a step, but I strongly recommend you first set your Visual Studio Color Theme to ‘Dark’. That is under Tools →Change Color Theme →Dark:

But, if you want the rest of the IDE to be with a different color theme, you can keep it if you wish. This tutorial will get as far as the line numbers and sidebar colors in the text editor, but won’t change colors for anything outside the text editor. I just think any theme outside of ‘Dark’ will probably end up looking weird 😜.

Step 2: Install The Enhanced Syntax Highlighting Tool

To apply all the colors from Monokai properly, we will need the Enhanced Syntax Highlighting tool by Stanislav Kuzmich.

So, quit Visual Studio, install that tool, and start up Visual Studio again.

Step 3: Modify the Necessary Colors

This is the annoying and time-consuming bit. We need to go into the ‘Fonts and Colors’ menu in Visual Studio and change each part of the syntax part by part.

As far as I know, there is no way to do this with an automated process. 😒

Instead, I will give you the key-value pairs of ‘User Tags’ and ‘User Types’, in the same order as they show up in the ‘Fonts and Colors’ menu!

First, go to Tools →Options:

Then in the popup, Environment →Fonts and Colors:

Display Item and Foreground / Background Values

I’ll use bold, italics, and a series of hyphens and commas to easily designate which values need to be filled.

Example:

Display Item: Item foreground or Item background-red value, green value, blue value (resulting color)

Actual Values for C# Monokai Syntax Highlighting:

Plain Text: Item foreground-248,248,242 (off-white)

Plain Text: Item background-39,40,34 (off-black)

Selected Text: Item background-85,84,70 (dark gray)

Line Number: Item foreground-143,144,138 (gray)

Line Number: Item background-47,49,41 (off-black, slightly lighter than standard background)

Note that the rest of the values are all ‘Item foreground’:

Keyword: Item foreground-249,38,114 (Monokai magenta)

Number: Item foreground-174,129,255 (Monokai purple)

Operator: Item foreground-249,38,114 (Monokai magenta)

String: Item foreground-230,219,116 (Monokai yellow)

String -Verbatim: Item foreground-230,219,116 (Monokai yellow)

User Tags — Events: Item foreground-102,217,239 (Monokai blue)

User Tags — Fields: Item foreground-102,217,239 (Monokai blue)

User Tags — Fields (Constant): Item foreground-102,217,239 (Monokai blue)

User Tags — Fields (Inside Enums): Item foreground-102,217,239 (Monokai blue)

User Tags — Local Variables: Item foreground-248,248,242 (off-white)

User Tags — Methods: Item foreground-166,226,46 (Monokai green)

User Tags — Methods (Extension): Item foreground-166,226,46 (Monokai green)

User Tags — Methods (Static): Item foreground-166,226,46 (Monokai green)

User Tags — Namespaces: Item foreground-248,248,242 (off-white)

User Tags — Parameters: Item foreground-253,151,31 (Monokai orange)

User Tags — Properties: Item foreground-102,217,239 (Monokai blue)

User Types — Classes: Item foreground-102,217,239 (Monokai blue)

User Types — Delegates: Item foreground-102,217,239 (Monokai blue)

User Types —Enums: Item foreground-174,129,255 (Monokai purple)

User Types — Interfaces: Item foreground-174,129,255 (Monokai purple)

User Types —Modules: Item foreground-166,226,46 (Monokai green)

User Types — Structures: Item foreground-166,226,46 (Monokai green)

User Types — Type Parameters: Item foreground-166,226,46 (Monokai green)

Final Notes and Further Options / Customizing

I have no idea how this looks on other languages like C++ and F#, since I haven’t used them yet in Visual Studio. I’m focusing on native and ASP.NET core development with C#.

Additionally, you may want to change the colors of the different ‘User Tags’ and ‘User Types’ (Ex. do you want your static and non-static methods to both be green?)

Those are questions I’ll leave to you to answer, but the info I’ve provided is the minimalist implementation.

Another important note: I have made but one change to the original Ace Monokai them, and that was the highlighting color. I found it simply too dark in the Visual Studio environment somehow. I could hardly see what code I was selecting. If you wish to leave the highlighting color with the original value, then the value (‘Item background’) is:

Selected Text: Item background: 73,72,62 (quite dark gray)

VSSettings File

Michael Armes was kind enough to leave a link in the comments to a repository with the vssettings file(which I failed to think of in the first place 😃) Thanks, Michael! The contents of that file are here:

Thanks!

I hope you enjoyed that quick tutorial and can now sleep easy knowing you can still write C# in Visual Studio with the Monokai color scheme! 😄

Tutorials like these with all the screenshots and used values take a lot to write, and a clap or two gives me the motivation to write more of them!

-Chris

Written by

https://chrisfrew.in 👨‍💻Full Stack Software Engineer 🏠Austria/USA 🍺Homebrewer ⛷🏃‍Outdoorsman

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store