Set Syntax Coloring for User-Defined Keywords

Environment: Algorithms, Visual C++

This tip was proposed by Sairama Jamalapuram. Syntax coloring for user-defined keywords is used for C++ files only.

Here are the steps you need to take to enable syntax coloring for user-defined keywords. The steps are taken from the online help.

  1. In the same directory as msdev.exe (for Visual Studio .Net search for ...\Microsoft Visual Studio.NET\Common7\IDE\devenv.exe), use the Text editor or Windows Notepad to create a text-only file named usertype.dat.
  2. Add your keywords to usertype.dat, one keyword per line. Note: The usertype.dat file is read during initialization. It cannot be renamed, nor can it be reloaded during an editing session. The syntax coloring mechanism checks the usertype.dat file last. Thus, all previously defined color settings take precedence over the user-defined keywords.
  3. Save the file as a text-only file, exit, and then restart Visual Studio.
  4. From the Tools menu, choose Options.
  5. Select the Format tab.
  6. In the Colors box, select User Defined Keywords.
  7. Set the font, font size, foreground color, and background color to your preferences.
  8. Click OK.
  9. Restart DevStudio.

This tip requires you to create a text file with the keywords. This can mean a lot of typing, so I created one from the MFC browse file. This is a huge file but surprisingly DevStudio doesn't seem to be any slower. I do have 128 Mb RAM, though. The USERTYPE.DAT file I created contains all the symbols used by MFC including the Windows functions, Windows constants such as messages and styles, MFC classes and member functions, and a whole lot of other identifiers I don't even recognize. Feel free to trim down the file if you want.

Downloads

Download keyword file. This file is 181 Kb zipped and expands to 638 Kb.
Date Last Updated: August 11, 2003 ISO C99: 7.18 Integer types



Comments

  • Perl syntax coloring

    Posted by GidiN on 07/11/2004 12:13pm

    Hi,
    Do you have usertype.dat for perl syntax

    Reply
  • Dose anyone know how the add $perval word to usertype.dat file?HELP!!

    Posted by Legacy on 05/25/2002 12:00am

    Originally posted by: Eitan Yerushalmi

    I need help about how to add the word "$perval" to the usertype.dat file . I think that there is a problem with the "$" because just "perval" without the "$" works.
    Is there ant problem with the token "$" before the words in the usertype.dat file?

    Reply
  • OpenGL Keywords/Definitions (GL.H and GLU.H)

    Posted by Legacy on 05/22/2002 12:00am

    Originally posted by: Gautam N. Lad

    Hi,
    Here's a link to OpenGL keywords/definitions for
    you to put in your Usertype.dat file to hightlight
    OpenGL keywords/definitions in your Visual Studio.

    http://www.cubicdesign.com/opengl_usertype.txt

    NOTE: Make sure to read the opengl_usertype.txt file
    before copying the contents. Also, if I have left out
    any keywords, please let me know.

    Bye!
    --
    Gautam N. Lad
    http://www.cubicdesign.com

    Reply
  • is there syntax highlighting for openGL keywords ?

    Posted by Legacy on 12/19/2001 12:00am

    Originally posted by: ral

    I read about how "complicated" or better time-consuming it is, to define my own keywords to highlight so the question:
    
    did anybody find a .dat-file for openGL-commands?

    That would help me a lot i think
    thx & greetings from germany
    ral

    Reply
  • Is it possible to print the sources in color?

    Posted by Legacy on 01/22/2000 12:00am

    Originally posted by: Walter van Groningen

    I really like the ability of (some) Borland compilers to print the source code just like it's presented on the screen: in color.
    Does anyone know if this is possible with Microsoft Visual C++ 6? It'd be a great improvement to me for code-readability...

    Reply
  • Define Non-C++ comment characters

    Posted by Legacy on 11/11/1999 12:00am

    Originally posted by: Alex Pare

    Hello,

    I'm trying to visualise FORTRAN source code in the MS Visual C++ editor. I just added the usertype.dat file to my PC and it works fine. However, I'd like to know if there is a way to color my FORTRAN comments (lines starting with C in the first column or anything after the ! operator on a line). It'll be great to be able to redefine the definition of a comment.


    Reply
  • I dont have a 'format' tab in vc6

    Posted by Legacy on 09/17/1999 12:00am

    Originally posted by: Benner

    Were do I find this 'Format' tab?? It's not in my options dlg!!

    Reply
  • Excellent feature

    Posted by Legacy on 07/27/1999 12:00am

    Originally posted by: Erez Efrati

    It works great! Thanks.

    Reply
  • Generate class list from visual studio

    Posted by Legacy on 06/02/1999 12:00am

    Originally posted by: Pieter Clarysse

    I'm working on a project with about a thousand classes.
    It would be great if you could explain me how you create the
    text file from the MFC browse file.
    I don't feel like typing in all our classes when I see them
    everywhere : in the class view, in the wizard bar, ...

    Reply
  • Multiple distinct user-type coloration?

    Posted by Legacy on 04/13/1999 12:00am

    Originally posted by: Adam S. Freimark

    It'd sure be nice to be able to have the MFC words in
    one color and a project-specific set of keywords in
    another...

    Possible at all? (VC6.0Pro)

    Reply
  • Loading, Please Wait ...

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

Top White Papers and Webcasts

  • Live Event Date: August 20, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT When you look at natural user interfaces as a developer, it isn't just fun and games. There are some very serious, real-world usage models of how things can help make the world a better place – things like Intel® RealSense™ technology. Check out this upcoming eSeminar and join the panel of experts, both from inside and outside of Intel, as they discuss how natural user interfaces will likely be getting adopted in a wide variety …

  • "Security" is the number one issue holding business leaders back from the cloud. But does the reality match the perception? Keeping data close to home, on premises, makes business and IT leaders feel inherently more secure. But the truth is, cloud solutions can offer companies real, tangible security advantages. Before you assume that on-site is the only way to keep data safe, it's worth taking a comprehensive approach to evaluating risks. Doing so can lead to big benefits.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds