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.NETCommon7IDEdevenv.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

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read