Skip to content
October 9, 2010 / Arthy303

Defining Keywords in Visual C++

This post is about defining custom keywords in Visual C++. Microsoft’s IDE, even the 2010 version, lacks the feature to show user-defined keywords (for example, names of classes you create) in the default blue color used for standard keywords (like int).

While this can be rather annoying, there is a simple way to solve the problem. However, if you have a large number of classes, structures, enums, it can become a bit tedious. If you think it is worth the effort, then, by all means, do it. Anyway, this is how it’s done:

Step 1. Go to the location on your computer where you installed Visual C++. Inside the installation folder, there should be a folder named Common7. Inside the Common7 folder, search for a folder called IDE. The IDE folder should contain the Visual C++ executable. Create a text file called usertype.dat in the IDE directory. Generally speaking, path of the usertype.dat text file should be: Installation Folder\Common7\IDE\usertype.dat.

UserType Location

Step 2. Open the usertype.dat file with Notepad or another text editor. Type your keywords in the file, each on a separate line. After you’ve added all the keywords, save the file.

UserType Example

Step 3. Exit and restart Visual Studio.

If you want to change the appearance of your custom defined keywords, you can. For this, you have to go to Tools > Options > Fonts and Colors and in the Display items list, select C/C++ User Keywords. You should be able to change the font, the foreground and the background color of your keywords.

Changing custom keywords colors

To find out more, visit this page. That’s it, you are done! Thank you for reading this post. Until next time, happy coding!



Leave a Comment
  1. Jason Doucette / Apr 22 2011 6:39 am

    Thanks for making the post, and the follow up. You are quite correct, and it works. Strange that they added another user type option, left the old one in, and then ignored the old one… weird. Anyways, thanks a ton!! šŸ™‚

  2. Arthy303 / Apr 21 2011 8:58 pm

    Hello … To change the color of your custom defined keywords, just go to Tools > Options > Fonts and Colors and from the Display items list select C/C++ User Keywords, not User Types. You will see the difference as soon as you click OK. (This is in Visual C++ Express 2010, but it should be the same in VS 2008)

    Thanks for reading my post.

  3. Jason Doucette / Apr 21 2011 7:43 am

    I just tried this in VC++ 2010 Express, and while it does load the usertype.dat file, it colors them all blue, instead of the maroon color I’ve chosen for “user types” under the color options. What gives?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: