visual-studio Visual Studio 格式化——更改方法颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2806420/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Visual Studio Formatting -- Change Method Color
提问by Daniel
The default appearance of a method for example, ".ToString()" is by default the color black. I want to make it a different color to stand out but I do not see any options that reference this option specifically.
例如,“.ToString()”方法的默认外观默认为黑色。我想让它与众不同,但我没有看到任何专门引用此选项的选项。
I remember one of former collegues showing me his VS IDE years ago and he had it setup this way but I cannot recall what he did.
我记得几年前一位前同事向我展示了他的 VS IDE,他是这样设置的,但我不记得他做了什么。
Does anyone have any ideas on how to do this?
有没有人对如何做到这一点有任何想法?
采纳答案by Hans Passant
The built-in syntax highlighters use lexical analysis. A lexer can classify identifiers, comments, literals, numbers, keywords. The parts you find back in the Tools > Options > Environment > Fonts and Colors dialog.
内置语法高亮器使用词法分析。词法分析器可以对标识符、注释、文字、数字、关键字进行分类。您可以在“工具”>“选项”>“环境”>“字体和颜色”对话框中找到的部分。
Recognizing that an identifier is a method, property, field requires parsing. Parsing generally only works well when you've got a well-formed program, you rarely have one while you are typing code. So wasn't favored by Microsoft. You can find alternatives in the Visual Studio gallery.
识别标识符是方法、属性、字段需要解析。解析通常只有在您拥有格式良好的程序时才能很好地工作,而在您输入代码时很少有这样的程序。所以并没有受到微软的青睐。您可以在Visual Studio 库中找到替代方案。
回答by Levi Fuller
You can do this with an extension: SemanticColorizeris what I use.
你可以用一个扩展来做到这一点:SemanticColorizer就是我使用的。
Tools-> Extensions and Updates-> Online-> Search for SemanticColorizer
工具->扩展和更新->在线-> 搜索SemanticColorizer
It allows you to modify the colors of methods, static functions, constants, member variables, and just about anything else you can think of.
它允许您修改方法、静态函数、常量、成员变量以及您能想到的任何其他内容的颜色。
回答by Jorge Picco
Go to Visual Studio "Tools>Options>Environment>Fonts and Colors" the menu shows a "Display Items" list, select "Identifiers"(out of which 'methods' is a member). Use the format controls to personalize the displaying of your chosen item. Unfortunately, variables, instances and namespaces are members of "Identifiers" so they will affected too.
转到 Visual Studio“工具>选项>环境>字体和颜色”菜单显示“显示项目”列表,选择“标识符”(其中“方法”是其中的一个成员)。使用格式控件来个性化您选择的项目的显示。不幸的是,变量、实例和命名空间是“标识符”的成员,因此它们也会受到影响。
If you are using Resharper then a more specific list of items is displayed.
如果您使用的是 Resharper,则会显示更具体的项目列表。
回答by Ian
For Visual Studio 2010
对于 Visual Studio 2010
Tools > Options
工具 > 选项
Environment > Fonts and Colors
环境 > 字体和颜色
Change "User Types"
更改“用户类型”
回答by Stanislav Kuzmich
For myself, I wrote a simple, lightweight "editor classifier extension" for Visual Studiobased on the async Roslyn APIsto Syntax Highlightinguser tags in C#and Visual Basiccode.
对于我自己,我基于异步Roslyn API为Visual Studio编写了一个简单、轻量级的“编辑器分类器扩展”,以使用C#和Visual Basic代码对用户标签进行语法高亮显示。
It has syntax highlightingfor:
它具有语法突出显示:
- "Events"
- "Fields"
- "Fields (Constant)"
- "Fields (Inside Enums)"
- "Local Variables"
- "Methods"
- "Methods (Extension)"
- "Methods (Static)"
- "Namespaces"
- "Parameters"
- "Properties"
- “事件”
- “领域”
- “字段(常量)”
- “字段(枚举内部)”
- “局部变量”
- 《方法》
- 《方法(扩展)》
- “方法(静态)”
- “命名空间”
- “参数”
- “属性”
In the future, perhaps coming on the "syntax highlighting" for something else.
将来,也许会出现“语法突出显示”的其他内容。
You can install this extension from the Visual Studio Marketplaceby following the link below:
您可以通过以下链接从Visual Studio Marketplace安装此扩展:
Download: "Enhanced Syntax Highlighting".
下载:“增强的语法高亮”。
You can change the syntax highlighting settingsby going to "Tools" > "Options" > "Environment" > "Fonts and Colors" > "Text Editor" and scrolling to properties starting with the prefix "User Tags - ...".
您可以通过转到“工具”>“选项”>“环境”>“字体和颜色”>“文本编辑器”并滚动到以前缀“用户标签-...”开头的属性来更改语法突出显示设置。
The syntax highlightingoptions for "Classes", "Delegates", "Enums", "Interfaces", "Modules", "Structures" and "Type Parameters" are just below, they have the prefix "User Types - ..." and are built-in default.
“ Classes”、“ Delegates”、“ Enums”、“ Interfaces”、“ Modules”、“ Structures”和“ Type Parameters”的语法高亮选项就在下面,它们有前缀“ User Types - ...”和是内置的默认值。
Good luck.
祝你好运。
回答by Juned Khan Momin
To change the color of the Method Calls go to
要更改方法调用的颜色,请转到
Tools > Options > Environment > Fonts and Colors > User Members - Methods > Item foreground Color > Select desired color.
工具 > 选项 > 环境 > 字体和颜色 > 用户成员 - 方法 > 项目前景色 > 选择所需的颜色。
This will also work in Visual Studio 2019.
这也适用于 Visual Studio 2019。
回答by Dave Robinson
Semantic Colorizer didn't work for me (VS 2019 Preview).
语义着色器对我不起作用(VS 2019 预览版)。
Enhanced Syntax Highlighting did exactly what I needed.
增强的语法突出显示正是我所需要的。
回答by Banana Cake
In VS 2019 go to Tools - Options - Text Editor - C# - Advanced - Editor Color Scheme and change it to Visual Studio 2019. Method names are now colored and everything has little bit better colors.
在 VS 2019 中,转到工具 - 选项 - 文本编辑器 - C# - 高级 - 编辑器配色方案并将其更改为 Visual Studio 2019。方法名称现在已着色,并且所有内容都有更好的颜色。
回答by Stefan27
Thanks to "@Ian" said User Types. For me "User Members - Methods" worked.
感谢“@Ian”说用户类型。对我来说,“用户成员 - 方法”有效。
- Tools
- Options
- Enviromment
- Fonts and Colors
- In Display items: "User Members - Methods"
- Change Item foreground
- 工具
- 选项
- 环境
- 字体和颜色
- 在显示项目中:“用户成员 - 方法”
- 更改项目前景
回答by Charlie Salts
Tools > Options > Environment > Fonts and Colorshas an extensive list of things you can change both font face, font size, color, style, etc.
工具 > 选项 > 环境 > 字体和颜色有一个广泛的列表,您可以更改字体、字体大小、颜色、样式等。
Also, Jeff Atwood had a great post a few years ago about IDE font and colour schemesthat you might find interesting.
此外,Jeff Atwood 几年前发表了一篇关于IDE 字体和配色方案的精彩帖子,您可能会觉得很有趣。

