开发者

Visual Studio Formatting -- Change Method Color

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.

I remember 开发者_JAVA技巧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.

Does anyone have any ideas on how to do this?


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.


You can do this with an extension: SemanticColorizer is what I use.

Tools -> Extensions and Updates -> Online -> Search for SemanticColorizer

It allows you to modify the colors of methods, static functions, constants, member variables, and just about anything else you can think of.


For Visual Studio 2010

Tools > Options

Environment > Fonts and Colors

Change "User Types"


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.


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.

If you are using Resharper then a more specific list of items is displayed.


For myself, I wrote a simple, lightweight "editor classifier extension" for Visual Studio based on the async Roslyn APIs to Syntax Highlighting user tags in C# and Visual Basic code.

It has syntax highlighting for:

  • "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 Marketplace by following the link below:

Download: "Enhanced Syntax Highlighting".

You can change the syntax highlighting settings by going to "Tools" > "Options" > "Environment" > "Fonts and Colors" > "Text Editor" and scrolling to properties starting with the prefix "User Tags - ...".

The syntax highlighting options for "Classes", "Delegates", "Enums", "Interfaces", "Modules", "Structures" and "Type Parameters" are just below, they have the prefix "User Types - ..." and are built-in default.

Good luck.


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.


Thanks to "@Ian" said User Types. For me "User Members - Methods" worked.

  1. Tools
  2. Options
  3. Enviromment
  4. Fonts and Colors
  5. In Display items: "User Members - Methods"
  6. Change Item foreground


Semantic Colorizer didn't work for me (VS 2019 Preview).

Enhanced Syntax Highlighting did exactly what I needed.


Tools > Options > Environment > Fonts and Colors has 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 schemes that you might find interesting.


In a previous version of visual studio (I think 2010) there was a plugin that allowed you to color code methods. I don't remember the name of it now as we have continued to progress forward in versions. The author did not keep up with the version updates of VS.

Update: VS10x allows you to color code methods in Visual Studio all the way through VS2015. A link to the authors Visual Studio Galleries page can be found here: https://visualstudiogallery.msdn.microsoft.com/1c54d1bd-d898-4705-903f-fa4a319b50f2?SRC=VSIDE

I am currently using this in VS2013 successfully.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜