Visual Studio Syntax Highlighting for C# Files

Environment: Visual Studio and C#

Here are the instructions necessary to have Visual Studio syntax-highlight your C# files.

  1. Locate the following key in your registry (using regedit or any other registry editor):

    HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Text Editor\Tabs/Language Settings\C/C++\FileExtensions

    This value will contain a value like the following:

    cpp;cxx;c;h;hxx;hpp;inl;tlh;tli;rc;rc2

    Simply add the .cs extension to the end as in this example:

    cpp;cxx;c;h;hxx;hpp;inl;tlh;tli;rc;rc2;cs

  2. Download the usertype.dat file (at the bottom of this document) and copy it to the same directory as msdev.exe (Visual Studio editor) (By default this will be c:\program files\microsoft visual studio\common\msdev98\bin). This file contains all the C# keywords

Downloads

Download (zipped) usertype.dat file (containing C# keywords) - 1 Kb


About the Author

Tom Archer - MSFT

I am a Program Manager and Content Strategist for the Microsoft MSDN Online team managing the Windows Vista and Visual C++ developer centers. Before being employed at Microsoft, I was awarded MVP status for the Visual C++ product. A 20+ year veteran of programming with various languages - C++, C, Assembler, RPG III/400, PL/I, etc. - I've also written many technical books (Inside C#, Extending MFC Applications with the .NET Framework, Visual C++.NET Bible, etc.) and 100+ online articles.

Comments

  • interested in uk payday loans not brokers

    Posted by Nuptsmeashhem on 05/02/2013 06:47am

    Finish Heist of your Centuries Mission in FNV - Deceased Money Suggestion 2 It is advisable to run genuinely fast in the stairs as well as go to the critical, turn with the alarm system then quickly get of the rail payday loans uk. Loan modification reviews show that home loan payments have greatly helped individuals to get back on their particular feet fiscally Payday loans help you get past the rough areas and allow you to get yourself back on track when the surprising forces you to generate hard money decisions This may lead to sky rocketing interest rates and a banking program failure a whole lot worse than way back in 2008

    Reply
  • Solution for Visual Studio .net

    Posted by Legacy on 03/08/2003 12:00am

    Originally posted by: Subsist

    It took me a while to find an equivalent in VS .net. I wanted to do highlighting and autoformatting for .java files.

    I stumbled across one:
    http://udn.epicgames.com/pub/Technical/UnrealScriptHighlighting/
    They give the following .reg file to perform syntax highlighting on .uc files.

    Modifying the .reg file they provide will force .java files to be highlighted as C syntax:

    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.0\Languages\File Extensions\.java]
    @="{B2F072B0-ABC1-11D0-9D62-00C04FD9DFD9}"

    Just stop VS .net, name the above file java.reg or something and double click on it, then start VS .net.

    Use the usertype.dat fix to add java keywords for highlighting. Now you will be able to autoformat and syntax highlight .java files. The only drawback is that C files will also be highlighted with java keywords, but that's a small price to pay.

    Reply
  • Same approach works for Java

    Posted by Legacy on 01/08/2002 12:00am

    Originally posted by: Preston L. Bannister

    You can of course use the same approach to get
    syntax coloring for your Java source files.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • VMware vCloud® Government Service provided by Carpathia® is an enterprise-class hybrid cloud service that delivers the tried and tested VMware capabilities widely used by government organizations today, with the added security and compliance assurance of FedRAMP authorization. The hybrid cloud is becoming more and more prevalent – in fact, nearly three-fourths of large enterprises expect to have hybrid deployments by 2015, according to a recent Gartner analyst report. Learn about the benefits of …

Most Popular Programming Stories

More for Developers

RSS Feeds