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.
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.
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.
To find out more, visit this page. That’s it, you are done! Thank you for reading this post. Until next time, happy coding!