Set Syntax Coloring for User-Defined Keywords


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

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.


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


  • Perl syntax coloring

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

    Do you have usertype.dat for perl syntax

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

    Posted by Legacy on 05/25/2002 07: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?

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

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

    Originally posted by: Gautam N. Lad

    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.


    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.

    Gautam N. Lad

  • is there syntax highlighting for openGL keywords ?

    Posted by Legacy on 12/19/2001 08: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

  • Is it possible to print the sources in color?

    Posted by Legacy on 01/22/2000 08: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...

  • Define Non-C++ comment characters

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

    Originally posted by: Alex Pare


    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.

  • I dont have a 'format' tab in vc6

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

    Originally posted by: Benner

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

  • Excellent feature

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

    Originally posted by: Erez Efrati

    It works great! Thanks.

  • Generate class list from visual studio

    Posted by Legacy on 06/02/1999 07: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, ...

  • Multiple distinct user-type coloration?

    Posted by Legacy on 04/13/1999 07: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

    Possible at all? (VC6.0Pro)

  • Loading, Please Wait ...

  • You must have javascript enabled in order to post comments.

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

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date