Change text color for selected text in Visual Studio

Possible duplicate:
I can’t edit the highlighted foreground text color in Visual Studio 2010. Does anyone know how to do this?

In the Options-> Environment-> Fonts and Colors dialog box , you can select Selected Text from the Displayed Items list, but this will allow you to change the background property of the item.

How to change the color of the text so that, for example, I can have white text on a blue background when I select an item? Also, is there a way to cross out the text (the Bold field is also disabled).

Note: Here is a question that asks about changing the background color.

+7
source share
3 answers

The foreground color in the VS2010 editor is not set in one place, and in many - in the Parameter Form. If you have Resharper installed, it also sets some foreground properties. The reason VS2010 is to allow individual elements (words) in the foreground to express different colors depending on their type (for example, comments, value types, enumerations, etc.), even if they are selected. In other words, VS2010 applies priority to the foreground color for these specific types in the general format of the selected text.

For example, when you look at the Fonts and Colors dialog, you will see an entry for user types. On my VS2010, its RGB value is RGB (43, 145, 175), which looks like a teal. If I change this color to red, the custom types in my foreground of the editor change to red and remain red even in the selection area.

In some cases, VS2010 overrides the foreground color, for example by applying a breakpoint to the line. On my VS2010 supported checkpoints, when in edit mode there is a white foreground color, regardless of the conditions in the line.

To answer the question of how to change the foreground color for all selected text, VS2010 does not support this out of the box.

I wrote the VS2010 extension as described here . I used the example code as is and added the lines:

  selectedText[EditorFormatDefinition.ForegroundBrushId] = Brushes.Green; formatMap.SetProperties("Selected Text", selectedText); 

... but that did not change the foreground color of the selected text to green. He stayed black. This is probably due to the WPF VS2010 editor using a Priority order for each format and one or more other formats that override the selected foreground text color.

+6
source

There are no individual settings for the Selected Text Foreground properties, it uses the Plain Text settings for Foreground in the Parameter Form, but this will only work for plain text, foreground colors for properties, comments and other specialties, the colored text will remain the same, there is no overriding of the foreground color which can be used for all elements.

+2
source

Have you tried setting the colors in the Highlighted Link option in the Fonts & Colors window?

+2
source

All Articles