76

Somehow part of my syntax highlighting for C# code has disappeared in the VS 2012 IDE. Uninstalling, rebooting, and reinstalling does nothing, nor does resetting the colors in the options dialog.

Here are some examples of items which all appear in default (black) that normally have color which don't:

  • Attributes
  • System classes
  • My own classes

And here are some keywords that still have color:

  • using
  • public
  • void
  • var
  • for

Has anyone else experienced this and managed to fix it?

Charles
  • 50,943
  • 13
  • 104
  • 142
Jedidja
  • 16,610
  • 17
  • 73
  • 112
  • 3
    Look at the color setting for 'User Types'. – leppie Jun 10 '12 at 16:33
  • Hmm - I only see C++ and VB User Types in the "Display items" listbox in Fonts and Colors options. Actually I don't see any C#-specific items at all. Maybe something is wrong there too? Although a complete uninstall and reinstall should have fixed that... – Jedidja Jun 10 '12 at 16:36
  • I also didn't see the "User Types" under "Tools" → "Options" → "Environment" → "Fonts and Colors" → "Display Items:". The solution of the accepted answer didn't do it for me. Eventually I tried the recipe from Leonardo Herrero below, deleting stuff from the AppData folder. It worked. Now I see the "User Types" option, and classes and structs are colored in the editor. – Jeppe Stig Nielsen Mar 23 '13 at 15:11

19 Answers19

101

Here is a simple solution. Go to the directory where devenv is (for 2012 RC), and type devenv.exe /setup. It will fix your problem.

devenv.exe is usually in something like C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE.

Edit: It has been suggested that you do this from the Visual Studio command prompt (Start>Microsoft Visual Studio>Tools>Visual Studio Command Prompt), and/or make sure your command prompt has administrator permissions.

Note for others: This has a very good chance of working for many other versions of Visual Studio, including 2008, 2010, 11 beta, ...

GregRos
  • 8,667
  • 3
  • 37
  • 63
  • 3
    Thank you!! :) That worked (and who thought losing colours would be so annoying). Note to anyone else that you have to run the command prompt as administrator otherwise. – Jedidja Jun 16 '12 at 15:32
  • 7
    +1, this didn't work for me first time from a standard Command Prompt, but then running it from a VS Command Prompt worked a treat, thanks :) – Town Aug 10 '12 at 17:10
  • 1
    This doesn't work for me. Uninstalling 2012RC Web Express did :) http://stackoverflow.com/questions/12197771/no-syntax-highlighting-or-intellisense-for-c-sharp-files-in-vs-2012 – ysrb Sep 08 '12 at 11:46
  • OH EM GEE!!!! /Setup worked!!!! i had to change back to one of the pre-installed themes (light), then i re-imported my theme again and VIOLA!!! i've been fighting this for days!! – hanzolo Nov 06 '12 at 23:16
  • 1
    +1 for this working but I still am not seeing my objects colored.....update it took a few minutes for objects to be colored light blue. – Bill Blankenship Nov 15 '12 at 14:50
  • Glad I saw @UserSmith's comment or I would have given up on this... seems that either it didn't work at first for me because I had VS2012 open, or I just needed to be patient and give it a few mins. – JCisar Dec 26 '12 at 22:36
  • I had this problem with web projects (not web sites). This (devenv /setup) worked, thank you. – Mr. TA Apr 02 '13 at 13:26
  • I had the same issue here, tried several other solutions, but only this one really solved the problem! Thanks! – Fabricio Apr 17 '13 at 18:14
  • Worked for me, thanks. I thought I was going to have to burn the midnight oil color blind for a minute there. – Wayne Weeks May 24 '13 at 02:54
  • 1
    Hey, I get a popUp saying "The operation could not be completed"..., has anyone experienced something like this? – Rick Aug 14 '13 at 20:00
  • This one worked for me except that I used "C:\Program Files\Microsoft Visual Studio 11.0\Common7\IDE" instead of "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE" – Lance Oct 19 '13 at 23:24
  • 1
    Works on Visual Studio 2013. Thanx. – Roman Plischke Oct 21 '13 at 12:14
  • At first it seemed as if it didn't work, but then colors magically appeared after re-opening all tabs. Thanks a lot! – Franz B. Dec 15 '14 at 09:32
32

My problem was limited to having the "DateTime" type not showing up in light blue like other class names. I fixed it by simply switching back-and-forth between VS Themes. Discovered by accident. Much quicker than reset settings or repair install...

VS menu Tools -> Change Color Theme

Marc-André
  • 321
  • 3
  • 2
  • 1
    This was a great answer to my problem, which also was with the color of "DateTime". Fixed! Thanks. – Nelson Reis Jan 17 '13 at 18:46
  • 2
    I had power tools installed and it would loose the color after restarting VS. Here is the permanent fix: http://stackoverflow.com/a/14297776/78739 – iheartcsharp Jul 23 '13 at 19:25
30

This is what worked for me:

1 - delete all in C:\Users\userNAme\AppData\Roaming\Microsoft\VisualStudio\11.0
2 - open vs console as administrator, and run:
      devenv.exe /setup
      devenv.exe /ResetSettings

This will reset all your environment settings.

Gaz Winter
  • 2,924
  • 2
  • 25
  • 47
  • This solved the problem for me. I had earlier had a free trial version of Visual Studio 2012 Ultimate (I think) but had now switched to Visual Studio 2012 Professional (on a paid license). I specualte that some "trash" from the previous VS2012 version was still left in the above AppData folder. – Jeppe Stig Nielsen Mar 23 '13 at 15:39
  • That was the only thing that worked for me. Much appreciated! – Warren Rox Sep 16 '13 at 15:18
  • This was what worked for me, as well. I suspect mine was a Resharper issue that carried over to a new machine. I got the project files back down from source control, but noticed that all of my syntax highlighting was gone. Resetting all settings didn't work for me (via GUI) -- and only doing these three steps did it finally start behaving well again. Thanks. – Jason Apr 22 '14 at 20:32
  • This worked for me. I tried just using the /setup first, that didn't work. But when I did the /ResetSettings it finally worked. Thanks. – Mike Jun 23 '15 at 12:34
  • This fixed it for me on Visual Studio 2013. During previous experimentation, I had already done step 1 and step 2A, but not the last 2B step! Thank you! – Aaron Reed Jun 01 '16 at 00:13
11

If none of the above work for you, delete all GUID-named folders under this registry key (make sure your Visual Studio instance is closed):

If you're using Visual Studio 2012: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\FontAndColors

If you're using Visual Studio 2013: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\FontAndColors

If you're using Visual Studio 2015: HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\FontAndColors

Restart Visual Studio, and you should see a few various "User Types" to configure. You can then import your Fonts and Colors that you backed-up, and everything will be good to go. This may also work for previous and future versions of VS, but I have not tested.

Disclaimer: Make sure you export/backup your current Fonts and Colors settings before making these registry adjustments. I cannot be held responsible for you losing your configs :)

Matt
  • 1,897
  • 4
  • 28
  • 49
  • I experienced the same problem and noticed I had no FontAndColors key. I created it, reopend VS and lo and behold! There were colors!! But, when I removed the key again, the colors stayed... – Peter Jun 07 '13 at 10:33
  • Not being an administrator on my work computer, this worked for me. Thanks! – ssn Apr 21 '16 at 12:32
9

If you still have this issue try ResetSettings (worked for me)

NOTE: this will reset the Visual Studio 2012 settings :)

1) close vs.

2)open cmd (as administrator).

3) go to devnev.exe folder (something like "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE" ).

4) type "devnev.exe /ResetSettings"

5) open vs and look at the beautiful colors

AssafDamari
  • 135
  • 1
  • 5
8

Found the source of the problem: If you have the "Productivity Power Tools 2012" installed,

you should go to Tools -> Options -> Productivity Power Tools and turn off the "Colorized Parameter Help" option.

This fixed the syntax highlight problem.

Nir Kornfeld
  • 827
  • 7
  • 11
  • Also described in http://stackoverflow.com/questions/14253879/visual-studio-2012-code-highlighting-for-structs/14297776#14297776 – Shaun Wilson Jul 23 '13 at 20:52
  • That article talks about the Color property... Anyway, I guess that Power Tools option causes many problems. – Nir Kornfeld Aug 13 '13 at 09:24
7

If anybody runs in to the same problem for Visual Studio 2013 as I did, the only solution that worked for me was to first close VS2013 and then delete the following registry key:

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\FontAndColors

After reopening VS2013, my syntax highlighting for types was restored.

Prior to deleting the registry key, I noticed that all of the "User Types..." settings in the Fonts and Colors section of Tools > Options were missing. Deleting the registry key restored them. They attained their default values which gave me the syntax highlighting colors I was looking for.

This was the only solution that worked for me. Switching themes, resetting my personalized settings to defaults, running devenv.exe with various command line switches to setup/reset Visual Studio did not work.

I also created the following bug report with Microsoft on their Connect site:

http://connect.microsoft.com/VisualStudio/feedback/details/810985/incorrect-syntax-highlighting-for-c-types.

prlcutting
  • 379
  • 2
  • 12
4

For me "Productivity Power Tools 2012" was the cause. Nothing suggested here helped. After removing the Power Tools the colors came back.

Peter Hedberg
  • 3,487
  • 2
  • 28
  • 36
2

I did all the things listed here and still nothing (VS2013 Update 3). I tried /setup, /resetsettings, deleting the stuff in AppData, deleting the registry keys. Still, User Types wouldn't be highlighted even in the default color scheme.

What helped in the end was opening the Fonts and Colors dialog, selecting Identifier, and making it Bold. Then removing the Bold. Instant fixage!

Roman Starkov
  • 59,298
  • 38
  • 251
  • 324
0

I had the same issue....just uninstalling and re-installing alone did not correct the problem. After I un-installed, deleted all remnants of VS 2012 in program files, removed all related registry keys, and deleted the VS 2012 folder from My Documents, then re-installed, user types showed up in the display items in fonts and colors and everything went back to normal. My guess is that it was an issue with one or more of the registry keys but I can't be sure of that.

mevans
  • 1
0

exit devenv

go to below path hkey_current_user\software\microsoft\visualstudio!

remove 9.0 , 10.0 , 10.0_config (i mean to say all other folders except 11.0 and 11.0_config)

Now start devenv and see the magical colors get back normal

David Nehme
  • 21,379
  • 8
  • 78
  • 117
Rashmin Javiya
  • 5,173
  • 3
  • 27
  • 49
  • Please don't SHOUT at us. It will be helpful if you edit your answer to keep only the necessary caps, such as for HKEY_CURRENT_USER. – Code-Apprentice Oct 10 '12 at 19:02
  • uuuuuhhhhhh, got a flashback back to the eighties! – nalply Oct 10 '12 at 19:27
  • I'd upvote this answer because it led me to the solution (a corrupt VS11 registry key, in addition to the regular 11.0 and 11.0_config keys) if it were only a bit more clear. – Dave Dec 11 '12 at 15:56
0

1 - delete all in C:\Users\userNAme\AppData\Roaming\Microsoft\VisualStudio\11.0 2 - open vs console as administrator, and run: devenv.exe /setup devenv.exe /ResetSettings1 - delete all in C:\Users\userNAme\AppData\Roaming\Microsoft\VisualStudio\11.0 2 - open vs console as administrator, and run: devenv.exe /setup devenv.exe /ResetSettings

This is what helped me...

Rishi
  • 1
0
  1. delete all in C:\Users\userNAme\AppData\Roaming\Microsoft\VisualStudio\11.0
  2. open vs console as administrator, and run:

    devenv.exe /setup
    devenv.exe /ResetSettings
    

This solution worked for me. Thanks alot Gaz Winter

manlio
  • 18,345
  • 14
  • 76
  • 126
0

If you've installed the preview of Roslyn, unintstall it. This worked for me.

Stelzi79
  • 585
  • 3
  • 12
0

After trying several of the solutions listed here, I eventually found that my issue was caused by a very large (488000+ characters) string variable. Highlighting was working up to that line, but not after it. Once I reduced the length of the string, highlighting in the rest of the file resumed working normally.

larreh
  • 1
0

I already had VS 2012 Pro installed on my machine. I then installed VS 2013 Pro and started facing this color issue. I then deleted the HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\FontAndColors key and opened VS 2013. This approach solved my issue and the colors were back.

Vipul
  • 43
  • 2
  • 7
0

If the windows desktop is configured with a high contrast theme the syntax coloring seems to disappear completely from Visual Studio. If this is the case, select a normal windows theme and set a solid background color (if you don't want a background pictures) to restore syntax coloring in VS.

0

Problem : Class name and Syntax showing in black color

Solutation:

Step 1: Remove Key :
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\FontAndColors

Step 2: Remove folder :
C:\Users\UserName\AppData\Roaming\Microsoft\VisualStudio\12.0

Step 3: Open command prompt (admin mode) and run below command line :
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE>devenv.exe /setup
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE>devenv.exe /ResetSettings

Shravan
  • 1
  • 1
-1

It work for download this "Productivity Power Tools 2012" and install, after install this tool get this steps go to Tools -> Options -> Productivity Power Tools and turn off the "Colorized Parameter Help" option.

This fixed the keyword as syntax ActionResult is not set for default black color and highlight problem resolved.