tags:

views:

294

answers:

3

MS Visual Studio editor highlights some non-keyword identifiers as keywords in C++ files. Particularly "event" and "array" are treated as keywords. That's very annoying to me, because they are not C++ keywords. I know how to add my own keywords to the list of syntax-highlighted identifiers, but how to remove existing built-in ones? I'm aware that this may require patching some executable files. So does anyone know how to do this?

+2  A: 

It doesn't look like a disable-syntax-coloring feature is exposed in a user-friendly way.

The only way I can think of selectively disabling syntax coloring is to create a new syntax coloring plugin for the IDE, and list all of the keywords you want colored. Microsoft gives information in this article on how to accomplish this task.

The drawback to this approach is that your IDE will now have two C++ languages and I'm not sure how it will select which plug-in to choose from once it loads a .h or .cpp file. However, this article suggests that you can override the existing C++ plug-ins by rewriting some registry keys.

Steve Guidi
That would get rid of all C++ IntelliSense features as well.
280Z28
A: 

I think the only "semi-practical" way to accomplish this to create a Visual Studio package that uses Text Markers to selectively cover up the keywords you don't want colored. Even that is not a little one-day task. Edit: Probably not even a full week task for someone not intricately familiar with the Visual Studio API and all its quirks, especially not getting it bug-free.

In other words, you probably want to just ignore them.

280Z28
+2  A: 

Thanks to article mentioned by Steve Guidi, I was able to find executable file that contains Colorizer and IScanner classes. It is named vcpkg.dll and located in /Microsoft Visual Studio 8/VC/vcpackages. (I'm using Visual C++ 2005 Express Edition, things may be different in other versions.)

The vcpkg.dll contains null-terminated UTF-16 encoded strings. I've opened it with hex editor, and searched for "array". There is only one such string in the file, so I've replaced it with "arrry". (It is important to maintain relative alphabetical order with respect to other keywords.) Then I've searched for "event", it shows up in several places, but there is only one that isn't part of some longer string, so I've replaced this one with "evvvt". After starting Visual Studio, it turned out that "array" and "event" weren't any longer highlighted, but "arrry" and "evvvt" were!

Of course this is an ugly hack, and it will void your warranty, and probably goes against Microsoft EULA, but what a relief for the eyes! Anyway, if you want to do it, be careful and remember to backup the file.

robson3.14