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: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • Businesses are moving more and more of their customer transactions to the web. Security is understandably a top concern as online transactions increase, so it is important to make sure your electronic signature provider meets the highest security standards. That means more than simply passing a security audit or obtaining a certification. This white paper provides recommendations for taking a broader view of e-signature security, and answers key questions that help identify the security requirements against …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds