In Visual Studio, you can customize the font and color of any display items such as C++ keywords, C++ parameters, C++ local variables, function names, macros, etc. You can do so through selecting the menu "Tools -> Options -> Fonts and Colors".
In the setting dialog, I am confused by two "Display Items": "C++ Local Variables" and "C++ Variables".
"C++ Local Variables" is easy to understand. Say:
void f()
{
int this_is_a_Cpp_Local_Variable;
}
I can set the C++ Local Variables to any font and color as I like.
However, I cannot understand what the "C++ Variables" are. I have tested and proved they are not global variables, no matter the global variable is a fundamental type or a user-defined type.
My question is: What's a "C++ Variable" in Visual Studio's "Display Items"?
Updates:
My test code is:
#include <iostream>
#include <functional>
using namespace std;
class A
{
public:
int n;
};
A a;
class B
{
public:
B()
{
int v;
a.n
}
};
void f(A a)
{
a.n;
}
int main()
{
int v;
A a;
}
The vssettings:
<UserSettings>
<ApplicationIdentity version="11.0"/>
<ToolsOptions>
<ToolsOptionsCategory name="Environment" RegisteredName="Environment"/>
</ToolsOptions>
<Category name="Environment_Group" RegisteredName="Environment_Group">
<Category name="Environment_FontsAndColors" Category="{1EDA5DD4-927A-43a7-810E-7FD247D0DA1D}" Package="{DA9FB551-C724-11d0-AE1F-00A0C90FFFC3}" RegisteredName="Environment_FontsAndColors" PackageName="Visual Studio Environment Package">
<PropertyValue name="Version">2</PropertyValue>
<FontsAndColors Version="2.0">
<Categories>
<Category GUID="{58E96763-1D3B-4E05-B6BA-FF7115FD0B7B}" FontName="Fixedsys Excelsior 3.01" FontSize="12" CharSet="1" FontIsDefault="No">
<Items/>
</Category>
<Category GUID="{75A05685-00A8-4DED-BAE5-E7A50BFA929A}" FontName="Fixedsys Excelsior 3.01" FontSize="12" CharSet="1" FontIsDefault="No">
<Items>
<Item Name="Literal" Foreground="0x000000FF" Background="0x01000001" BoldFont="No"/>
<Item Name="String" Foreground="0x000000FF" Background="0x01000001" BoldFont="No"/>
<Item Name="CppMacroSemanticTokenFormat" Foreground="0x000000FF" Background="0x01000001" BoldFont="No"/>
<Item Name="CppEnumSemanticTokenFormat" Foreground="0x000000FF" Background="0x01000001" BoldFont="No"/>
<Item Name="CppGlobalVariableSemanticTokenFormat" Foreground="0x000000FF" Background="0x00008000" BoldFont="No"/>
<Item Name="CppLocalVariableSemanticTokenFormat" Foreground="0x00000080" Background="0x01000001" BoldFont="No"/>
<Item Name="CppParameterSemanticTokenFormat" Foreground="0x00000000" Background="0x01000001" BoldFont="No"/>
<Item Name="CppTypeSemanticTokenFormat" Foreground="0x00FF0000" Background="0x01000001" BoldFont="No"/>
<Item Name="CppRefTypeSemanticTokenFormat" Foreground="0x00FF0000" Background="0x01000001" BoldFont="No"/>
<Item Name="CppValueTypeSemanticTokenFormat" Foreground="0x00FF0000" Background="0x01000001" BoldFont="No"/>
<Item Name="CppFunctionSemanticTokenFormat" Foreground="0x00000080" Background="0x01000001" BoldFont="No"/>
<Item Name="CppMemberFunctionSemanticTokenFormat" Foreground="0x00000080" Background="0x01000001" BoldFont="No"/>
<Item Name="CppStaticMemberFunctionSemanticTokenFormat" Foreground="0x00000080" Background="0x01000001" BoldFont="No"/>
<Item Name="CppClassTemplateSemanticTokenFormat" Foreground="0x00FF0000" Background="0x01000001" BoldFont="No"/>
<Item Name="CppGenericTypeSemanticTokenFormat" Foreground="0x00FF0000" Background="0x01000001" BoldFont="No"/>
<Item Name="CppFunctionTemplateSemanticTokenFormat" Foreground="0x00000080" Background="0x01000001" BoldFont="No"/>
<Item Name="CppNamespaceSemanticTokenFormat" Foreground="0x000000FF" Background="0x01000001" BoldFont="No"/>
<Item Name="CppLabelSemanticTokenFormat" Foreground="0x000000FF" Background="0x01000001" BoldFont="No"/>
<Item Name="VA X Brace Matching" Foreground="0x02000000" Background="0x02000000" BoldFont="Yes"/>
</Items>
</Category>
<Category GUID="{B36B0228-DBAD-4DB0-B9C7-2AD3E572010F}" FontName="Microsoft YaHei" FontSize="9" CharSet="1" FontIsDefault="No">
<Items>
<Item Name="Different content" Foreground="0x000014E5" Background="0x00FFFFFF" BoldFont="No"/>
<Item Name="Identical content" Foreground="0x00000000" Background="0x00FFFFFF" BoldFont="No"/>
<Item Name="Source Only" Foreground="0x00000000" Background="0x00FFFFFF" BoldFont="No"/>
<Item Name="Target Only" Foreground="0x00000000" Background="0x00FFFFFF" BoldFont="No"/>
<Item Name="Not Downloaded" Foreground="0x006D6D6D" Background="0x00FFFFFF" BoldFont="No"/>
<Item Name="Even Row Items" Foreground="0x00000000" Background="0x00FFFFFF" BoldFont="No"/>
<Item Name="Odd Row Items" Foreground="0x00000000" Background="0x00FFFFFF" BoldFont="No"/>
</Items>
</Category>
<Category GUID="{E0187991-B458-4F7E-8CA9-42C9A573B56C}" FontName="Fixedsys Excelsior 3.01" FontSize="12" CharSet="1" FontIsDefault="No">
<Items>
<Item Name="String" Foreground="0x000000FF" Background="0x01000001" BoldFont="No"/>
</Items>
</Category>
<Category GUID="{FF349800-EA43-46C1-8C98-878E78F46501}" FontName="Fixedsys Excelsior 3.01" FontSize="12" CharSet="1" FontIsDefault="No">
<Items/>
</Category>
</Categories>
</FontsAndColors>
</Category>
</Category>
</UserSettings>
As you can see it highlights the different types of variables on your C++ projects. This is Visual Studio 2012 with a custom color scheme.
blue := local
green := global variable
So this is your code highlighted with my settings:
This is your colorsettings with background color red for local variables
User contributions licensed under CC BY-SA 3.0