user2630015
user2630015

Reputation:

Visual Studio 2012: Syntax Highlighting is turning off and on

I'm using VS2012 and I'm quite happy with it. But the problem is, whem I'm coding in C++, that the syntax highlighting is turning off an on all over again. Sometimes, the highlighting is off and I have to reload the file. Also, it highlighting is quite slow.

Does anyone know how to fix it?

Upvotes: 11

Views: 12120

Answers (9)

Qwertypal
Qwertypal

Reputation: 189

Personally, I found that things like:

#if 0// bla-bla

mess up syntax highlighting badly. The solution that works for is to put a space before a comment, like so:

#if 0 // bla-bla

Upvotes: 1

ChrisC
ChrisC

Reputation: 11

In my case, it turned out that a large block of code (a 200+ line method) was commented out with // starting in the first column, and this was causing the syntax coloring not to work. I changed the commenting delineation to /* ... */ for that method and all of the syntax coloring was fixed.

Upvotes: 1

adigostin
adigostin

Reputation: 638

For me, highlighting always stops working when the first visible line in the editor begins with the characters '//' and I trigger reparsing somehow (CTRL + S for instance).

Highlighting always works fine when the first visible line in the editor begins with anything else, even with a whitespace, and I trigger reparsing somehow.

I could indent all my comments and never experience this problem, but now that I know about it, it's not so annoying anymore, so I let it be.

Upvotes: 4

BiosHazard
BiosHazard

Reputation: 21

I had the same problem. Disabling the extentions sadly did not work for me.
After searching around and realizing that it only happened on larger files,
I got it to work by turning harware acceleration off.

Tools->Options...->Environment->General
*Automatically adjust [...] (off)
*Use hardware graphics acceleration (off)

Upvotes: 1

Kay
Kay

Reputation: 151

I know this is a while ago but I have had this same problem appearing randomly until just now.

It would disable when the last line in a file was a single line comment. (// blah blah). As soon as i removed that the text highlighting worked again!

Upvotes: 15

Sean Walsh
Sean Walsh

Reputation: 81

I installed Visual Studio 2012 Update 3 yesterday and started experiencing the exact same behavior described in the original post. Based on some suggestions in this thread, I took at look at my extensions, and disabling AllMargins fixed the issue. I've since re-enabled AllMargins and everything appears to be working as it should.

Try disabling and re-enabling any of your extensions; hopefully that will fix the issue for you.

Upvotes: 0

Iosif Murariu
Iosif Murariu

Reputation: 2054

If you're using only Intellisense, you may go to Edit->Intellisense->Toggle Completion Mode (or hit Ctrl + Alt + Space), play with it and see if it works (maybe you've pressed this combination of keys by accident).

I've also installed Update 3 and haven't had any problems since. Who knows..

Upvotes: 1

Sam Harwell
Sam Harwell

Reputation: 99859

Edit: In this answer I assume that your problem description is correct. In other words, I'm assuming that occasionally C++ highlighting is working, and the other times the text appears as plain text: completely black and white.

My guess is you are using an extension which modifies or replaces the way Visual Studio highlights C++ code. Try temporarily disabling all of your extensions and checking again if the editor is working. Some extensions might have the Disable button disabled; in that case you'll need to uninstall the extension for this test (possibly through Control Panel → Programs and Features).

As an example of one common extension that completely replaces the C++ highlighter is Visual Assist. However, I do not personally use that product and I haven't heard of any specific problems with it of this nature. I am merely mentioning it as an example of an extension that completely changes the behavior of Visual Studio in regards to syntax highlighting of C++ code.

Upvotes: 4

Related Questions