Fuck you, Microsoft: the sorry state of Visual Studio syntax highlighting

TL;DR: you can’t even choose a different colour for “return” and “float” in Visual Studio.

I mostly use Vim as my everyday editor. This is not the place to go through the details of why, but basically it does exactly what I want. One thing Vim does well for me is syntax highlighting. Here is a bit of Lol Engine C++ using Vim’s default colour scheme:

The colour scheme is simple here:

  • yellow for control flow
  • green for types and qualifiers
  • magenta for constants
  • light grey for everything else

You may notice that the vec3 or quat types, which are not C++ base types but which behave exactly as if, are coloured just like float. This is simply done by adding the following line to my main config file or to a separate configuration file:

au Syntax cpp syn keyword cType vec2 vec3 vec4 quat

Okay now I would like you to read that again.

  • yellow for control flow
  • green for types (including custom types) and qualifiers
  • I get all that shit by adding one single configuration line

And I am going to show you the pain it is to do the same in Visual Studio.

First Visual Studio attempt: usertype.dat

Since at least Visual Studio 2003, the usertype.dat file can be used to add a list of user types. This is still true in Visual Studio 2010. So let’s add those new types to usertype.dat:


Not quite there.

M_PI is not coloured, and if I add it to the list it becomes green instead of magenta, but let’s forget about it for now.

float and const are still yellow and there is no way to fix that! Of course I thought about adding them to the list of user types, but the scanner decides that they’re C++ keywords way before it checks for user types.

Second Visual Studio attempt: a Language Service add-in

Visual Studio add-ins are very powerful. Almost any part of the editor can be modified and augmented. There are hundreds of add-ins available and you can write your own.

This looks promising: you can write your own language handler, but you can certainly modify an existing one quite easily (or so I thought).

To handle a new language, you need to subclass the LanguageService class and you register that new class in Visual Studio. One of the methods you need to implement in the language service is GetScanner:

class MyLanguageService : LanguageService

    public override IScanner GetScanner(IVsTextLines buffer)
        return new MyScanner(buffer);

And the IScanner interface has a ScanTokenAndProvideInfoAboutIt method that is responsible for choosing the colour of tokens:

class MyScanner : IScanner

    bool IScanner.ScanTokenAndProvideInfoAboutIt(TokenInfo tokeninfo, ref int state)

        if (FoundKeyword)
            tokeninfo.Color = TokenColor.Keyword;
            return true;


This is brilliant. I mean, with such an architecture, you can implement your own sublanguage, add colour schemes, modify whatever you want. Honestly, this is perfect for my needs.

So here is the plan:

  1. find the LanguageService class responsible for parsing C++
  2. inherit from it and reimplement GetScanner() to use our own IScanner
  3. in our version of ScanTokenAndProvideInfoAboutIt, just call the C++ scanner’s version of ScanTokenAndProvideInfoAboutIt and inspect tokeninfo
  4. if the token info says this is a keyword, match that keyword with our list of types, and change its colour if necessary
  5. register our new language service with a higher priority

This sounds pretty simple and elegant. It’s some kind of two-level proxy pattern.

Except it has absolutely no chance to work. Because there is no language service class for C++.

That’s right. Visual Studio does not use its own advertised architecture to handle the C++ language. If you want to slightly change the behaviour of the C++ language service, you need to fully reimplement it. And by fully reimplement, that means fully, even the completion stuff for IntelliSense.

Third Visual Studio attempt: a Classifier add-in

A classifier add-in differs from a regular language add-in in that it only affects the text that is being displayed. It has no knowledge of the language syntax or structure or what the underlying parser has analysed, but it does know about what the underlying classifier did. For instance, it doesn't know whether a given chunk of text is a C-style or a C++-style comment, but it does know that it was classified as "comment".

This proved to be the correct thing to use! My Visual Studio colour scheme now looks a lot more like my Vim setup:

There are still limitations, but it's a good start. When another plugin comes in and has higher priority, it undoes everything my add-in did, which is arguably the fault of those other plugins, but I believe the lack of a properly pluggable architecture is definitely the issue.

Further thoughts

I know this is a rant, but I will nonetheless add my own constructive information here, as well as anything readers may wish to contribute.

There are other paths I have not explored yet:

  • disassemble the Visual Studio DLLs

I am pretty sure people will suggest that I use VAX (Visual Assist X). I am already using it. I am even a paying customer. In fact I asked for that feature more than three years ago and was more or less ignored (the only answer I got was about a minor point where the person thought I was wrong — I wasn’t). While most of the bugs I reported against VAX were fixed, I have a problem with their stance on accessibility, illustrated by their attitude on this bug. My general feeling is that VAX is a pathetic, slow and annoying piece of crap. The only reason I do not rant more about it is that I know how painful it is to write Visual Studio extensions.

I asked for advice on StackOverflow but since my problem is very specific and probably has no solution, it’s not surprising that I haven’t got any answers yet.

Someone wanted to extend the syntax colouring but was told that apparently “this can't be accomplished with an add-in”, “you may be looking at implementing a full language service to provide this feature” and “Todays language services are currently not architected to be extensible”. One suggestion was to replace a whole COM object using only its CLSID.

Another person wanted to leverage existing language services from within Visual Studio in order to use it for his own language, and was told it was not possible. The workaround mentioned in that thread involves creating a whole new virtual project that would mirror files, hide them, rename them to .c or .h, and analyse the result.


Honestly, the only reasons I still use Visual Studio are:

  • I use it at work
  • a lot of people use it and I need to provide them with a usable environment
  • there’s no other acceptable way to develop for the Xbox 360

But given how it sucks, and has sucked for years, and made my life miserable, and how some of the bugs I have reported back in 1997 are still present, I can only hope that this pathetic piece of crap either becomes opensource (wishful thinking) or just dies and we get something really extensible instead.

Attachments (3)

Download all attachments as: .zip


1. anonymous -- 2012-11-29 10:00

that's pretty ridiculous bashing, considering there really isn't ANY alternatives even near the convenience of what's VS good at ... some lacking with syntax highlighting is such a minor thing.

I've used a few of the competing IDEs (on various platforms) and when I got the chance to ditch them and just use VS, I've been much happier. :)

2. sam -- 2012-12-01 23:53

@anonymous that’s a pretty ridiculous argument, considering ALL the alternatives (XCode, Eclipse, Code::Blocks, codelite, various Linux IDEs…) cost exactly 0€ whereas Visual Studio Professional costs €1,283.65. So yeah I think some decent text editing features are expected.

3. anonymous -- 2012-12-02 16:19

VS Express versions have been free for quite many years now, and they're just fine for most things. I have had only a few rare times when I've longed for the pro version a bit (when wanting to try some plugin), but no any major reasons. At the very least, I think the VS Express beats 10-0 any of the other free ones... (and btw xcode does have a small cost nowadays)

PS. much appreciate that you're actually doing your best to fix the issue which nags you, by releasing VsLol... rather than just complaining. :) I guess this is an instance where the Pro version is needed though?

4. iarwain -- 2012-12-06 00:02

Sorry to pollute this comment section, but I'm actually sincerely curious to know to which features of VS Express @anonymous is referring, that makes it beat all the other free IDEs 10-0 for him/her. I have been using VS 6-2012 at work for the last 12 years and I'm still looking for a "best fit" editor/IDE at home. So far, Sublime Text 2 is the closest I've found.

5. David Pritchard -- 2013-07-22 15:45

Surely you can alter the colouring of types and keywords in the "Fonts and Colours" option page? At least in VS2008.

However, I sympathise generally about the poor quality of Visual Studio. It's bad and getting worse, especially for C++ users. In spite of the fact that .NET has not taken over the world in the way Microsoft hoped, they've pretty much abandoned C++. I've been wondering about migration options for a while now.

6. anonymous -- 2013-10-26 02:40

idiotic article - the fonts you're after look like something from the 1980s and the colours are shit too - visual studio is more standard compliant than GCC and the colours and fonts can all be altered to your choice. It's just a shame that Microsoft sell their software at a premium, limp out poorly tested software that has loads of bugs, and then get inexperienced monkeys with pigeon english to do 'support' these days, which really just entails fobbing people off.

7. A third anonymous -- 2013-10-30 17:27

Worst anonymous ever.

8. LostTime77 -- 2014-01-17 15:24

We are looking to try and integrate another compiler into the vc++ build system instead of doing a makefile project. I did a bunch of research, and the vc++ system doesnt support project sub types nor project types without re implementing the entire c++ language service. I wouldn't mind implementing my own language service and or project type if only we could get the intellisense / highlighting support from the vc++ editor. Its a complete pipe dream without re implementing it from scratch. What the hell good is visual studio extensibility if you cannot re use the features from the c++ service. It looks to me like the .NET visual studio sub system and the c++ sub system are two separate animals. The .NET system is much newer and was probably implemented and re architected to be extensible. The c++ system seems like something 2 guys made in 199X for VS1 and the microsoft team in their infinite wisdom has just been stringing it along and not remaking it. It's exactly the same scenario of why windows 7, and I bet windows 8 (Ive never used 8) still is using NT.dll in sys32 for the core which has been around for a decade.

9. oystein.krog -- 2014-03-02 11:36

Thought it's just in alpha right now, the new ReSharper C++ support is going to be really good I think, you should try it. (it might actually give you too much color though;P)

10. Siddharth -- 2014-03-02 11:45

This is ridiculous. You have the freedom to write, use it judiciously.

11. anonymous -- 2014-04-07 15:56

"visual studio is more standard compliant than GCC"

Thanks, I needed my laugh for the morning. Which C standard/dialect does MSVC support again? Oh, none? Good to know.

12. anonymous -- 2014-05-20 06:08

You can't use an environment variable in project output path. How sucky is that?

13. anonymous -- 2014-07-01 18:50

I wanted to support the writer - Microsoft Visual studio for C++ SUCKS!!! Try something simple like *adding an existing file as a class in an existing project in a specified subdirectory* to see how much the interface sucks.

14. anonymous -- 2014-07-02 22:48

You can integrate GVim in VS, but unfortunately, there is no simple means of mapping hotkeys and VIM functions to VS functionality (ie: code completion, source resolution, and a lot of awesome stuff you can do with CTAGS+VIM).


15. anonymous -- 2014-07-05 09:45

"idiotic article - the fonts you're after look like something from the 1980s" so we guess that you are under age may be 90s or even worst after millenium. Does your father know what you're doing with his computer?

"inexperienced monkeys with pigeon english...." It's call pidgin not pigeon ... and english should be with a capital letter English because is name of the language. As we see how good is your English we can guess how proficient you are in the computer languages... You just shine here

P.S. it is good idea to put security form against Internet trolls as most appropriate for them is IQ test instead of image capture :D

16. anonymous -- 2014-09-04 05:10

This is not only a stupid argument but also not helping others with anything. Next time you have ants in your pants don't blog about it, please!

17. anonymous -- 2014-09-26 05:28

Visual Studio entirely sucks.. I prefer over 100 times JAVA...studying web forms is a pain in the ass compared to jsp and servlets in java.

I'm tired of having to use a virtual machine to install that shit for the .NET development classes.

That shit installs like 40 programs and if I want to uninstall, I have to manually remove each one in some order, because if I do a bad uninstall I have to create a new virtual machine only to reinstall that shit for the university.

The code is shit too, the response.redirect bullshit and other stuff make me sick.

I can't believe that JAVA is a breeze for me, but when it comes to C# in ASP.NET is a pain in the ass, I hope I can graduate quickly from that shit,because I never want to see .NET in my student life again.

PD: Tomorrow I have a ASP.NET test and I wanted to discharge all my rage.

18. anonymous -- 2015-01-09 10:19


19. anonymous -- 2015-04-09 00:29

Can't agree more. Microsoft really shits the bed when it comes to proper syntax color control.

20. nutjob@gmx.net -- 2015-05-19 21:59

I love the Visual Studio IDE itself, even though it's by no means perfect. What I'm very disappointed in is the slow pace with which Microsoft goes about implementing all the "new" C++11 features in its compiler. It is now 2015, and they still aren't remotely supporting many C++11 features. As much as love working in VS, I have now switched to Qt Creator with the MingW compiler, which has far better C++11 support.

21. anonymous -- 2015-05-26 05:22

Would you be willing to post your classifier add-in files? Or, any new solution you've come up with? Having the same frustrations...

22. anonymous -- 2015-06-10 17:03

... How about we just stop with IDEs? They are all terrible and ass.

23. anonymous -- 2015-06-22 11:54

Annnd now VS costs 0($), happy Easter madafakas...

After 2013 Microsoft has changed so much that now not only it is much better than anything else (like it was before) but they are going more and more to open source. Now the Java fanboys have nothing else as an argument but a pure rage.

24. ryios -- 2015-08-01 09:56

I don't need something to be color coded to understand it. I know a declaration by the use of var or some type. I know a constant by it's lack of a variable. I know control statements by what they are IF, Switch, While, etc.

It doesn't suck, it's the best IDE ever created, and will be the best for sometime to come.

And by best, I mean VS2013 and VS2015.. They are awesome. I have a feeling if someone sat behind me and watched me use Visual Studio for an hour, they'd love it to and say things like "Oh man, I didn't know you could do that... Where is that documented.. What short cut was that it was so fast.. How did you auto indent that whole file with one key press... "Oh wow you can split your 3 code windows up onto 3 monitors and see all three classes at the same time!!".. "Did you just do a push to github with one click?".. "Did you just publish all 6 websites with 1 click?", "Did you just write c# that generates c# in the IDE window for you (TT Template)?" Are you managing that whole MS Sql Database in the IDE and in source control? What you can publish your SQL Database to distant sql servers!!! Did you just generate your data layer with a text template?

I could go on and on all day about all the awesome things you can do with visual studio... Not to mention I can run queries against any connected sql server without leaving my IDE (no need for SQL Management Studio, Navicat, or w/e you are using). And Unit Testing... And if I want to get really fancy I can create a VS Extension (knowing WPF) and make en extension to do what I want the IDE to do in no time.

25. anonymous -- 2015-08-08 22:55

For those reading this, there is an extension that adds flow control coloring and rainbow parentheses that you might be interested in. It's called Viasfora.

26. Manjia -- 2015-09-08 12:45

Definitely agree 1000% VS DO REALLY SUCKS IN SO MANY WAYS

27. anonymous -- 2015-09-17 13:41

And you can write codes in other shit languages (aka PHP) as well with some well written extensions

28. anonymous -- 2015-09-19 00:34

the only reason a dev would call vs better is the lack of experience using a serious programming language (not algol based) or ide like vim. ms ide is just so retarded dont even have duplicate line vi implemented this in the late 70s circa 78.

29. anonymoose -- 2015-10-27 19:57

...I feel kinda awkward here, the biggest issue I had with VStudio was with 2010, which seemed to hate #line directives with a passion. Haven't used the IDE for a while, but last I checked, it constantly spat out error messages that you can't use #line in a precompiled header (if I remember correctly), regardless of what type of project I was making, what type of file I was working with, or what the context was. #line just before main() in a single-file project that doesn't use any headers except the standard ones? NOPE! #line in a (non-precompiled) header, just before a class definition? NOPE! #line in a class' source code, before each of the member functions? NOPE! So... in lieu of its irrational hatred for #line and outright refusal to let me use it regardless of the standard or VStudio's settings, I've just been using Notepad & Notepad++ for coding, and VStudio command line for compiling. [On that note, it's strange that the command-line compiler doesn't have issues with #line, even though its IDE did.]

This might've just been my computer acting up, though, not sure. Going to try VS 2015 sooner or later and see if it's fixed.

30. 一部予約販売 最安値挑戦中 -- 2015-11-15 08:57

うわー、ゴージャス サイト。のthnx ... 一部予約販売 最安値挑戦中 http://bessonnitsy.net

31. anonymous -- 2015-12-03 19:21

I care about what my IDE can do and how much easier it makes my life, not what color "float" is.

As a full stack .net developer... I can't imagine not using Visual Studio... Especially with SSDT out now... I have all of our databases built as SSDT projects and when I want to make a change to a live database... I can just change it in SSDT and click "Publish" and out go my 6 altered stored procedures, 2 new views, and 12 modified columns. Not to mention it allows me to source control the database.

Then for our web apps... All support MSDeploy and Web.Config transformations... So I can make a markup change in an MVC view, and click publish, and out it goes "differential compare".

Now with 2015 we Have Shared Projects.... I can create a project that is basically nothing but a folder with files in it... I can link that project into any other project, causing those files to be built in the project linking to the shared project.


Shared Project -> SomeClass.cs

Consuming Project XYZ.Thing <- Links to Shared Project

Output Types XYZ.Thing.SomeClass

Shared Projects are also handy for sharing T4 Templates, that's another thing Visual Studio does "T4 Templates"...

I mentioned SSDT earlier... We'll I can use SQL T4 Templates in my SSDT project to automatically generate the SQL for an Audit Table for every table I make that I want an audit table for.

So say I make a table ID, FirstName, LastName

The t4 template makes an audit table for it VersionId, ID, FirstName, LastName..

(more detailed than that).

I could go on all Day about the crap I can do with Visual studio.

I think half peoples problem with it is that they have experience doing things in other IDE's, so they never discover just how capable Visual Studio is.. They get frustrated after a few weeks, or a month, and abandon it and the whole .Net platform.

32. anonymously prick -- 2015-12-31 04:32

what i'm really annoy with visual studio is..the lack of explanation in build your own extension, how to effectively using them..otherwise visual studio is the best (in my opinion) from several out there..i even code java in visual studio.. :)

33. anonymous -- 2016-06-16 20:17

Wait until you

34. anonymous -- 2016-06-16 20:19

Wait until you try to connect your .net shit to any other database other than Microsuck's SQL Server. .net absolutely SUCKS compared to Java!!!

35. Mr. C++ -- 2016-07-25 18:24

VS2015 is indeed riddled with bugs, however; the M$ hating people in here haven't used it and are mostly unaware of any of the real bugs. For instance, I am using it against MySQL and SQLite A LOT. It uses ODBC and OleDB to talk to databases. Neither of which are 'magically bound' to Microsoft SQL technology. I code against Linux and Windows. I even write most (not all) of my Linux code under it as it is clearly the best IDE on the market. I feel like the parent that can't get their f*king toddler to try corn, and yet; the toddler has already decided that it sucks because their cousin won't eat it. Please catch a clue people. Think for yourselves.

36. anonymous -- 2016-08-23 13:27

Hey, there is a cool extension called Codinion (https://visualstudiogallery.msdn.microsoft.com/504311cf-bd01-4b12-bca3-a3e5d9505b76) which adds a lot more options for syntax highlighting.

336. suba pron -- 2016-11-26 21:57

A5KINm Wow, great article post.Really thank you! Really Cool.

Add New Comment