Change text color for Selected Text in Visual Studio [duplicate]
Asked Answered
P

3

9

Possible Duplicate:
I can't edit selected text foreground color in Visual Studio 2010. Anyone know how to do this?

In the Options->Environment->Fonts and Colors dialog you can choose Selected Text in the Display Items listbox, but this only allows you to change the Item background property.

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

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

Pattison answered 4/7, 2012 at 0:8 Comment(1)
which version of visual studio are you usingEnemy
N
6

The foreground color in the VS2010 editor is not set in one place but in many within the Options Form. If you have Resharper installed it also sets some foreground properties. The reason VS2010 does this is to allow individual items (words) within the foreground to express different colors depending on their type (e.g. comments, value types, enums etc.) even when they are selected. In other words VS2010 applies a priority to the foreground color for these specific types over the generic selected text color format.

For instance, when you look at the Fonts and Colors dialog you will notice the entry for User Types. On my VS2010 its RGB value is RGB(43, 145, 175) which looks like teal. If I change that color to Red, the User Types on my editor's foreground color changes to Red and remains Red even when with the selection area.

In some instances VS2010 will override the foreground color such as applying a breakpoint to a line. On my VS2010 enabled breakpoints when in editing mode have a white foreground color, regardless of the terms in the line.

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

I wrote a VS2010 Extension as outlined here. I used the example code as is and added the lines:

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

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

Nepil answered 14/7, 2012 at 12:43 Comment(0)
S
4

Have you tried setting the colors on the 'Highlighted Reference' option in the Fonts and Colors window?

Sharp answered 9/7, 2012 at 2:15 Comment(1)
Tried it, doesn't work for selected text.Pattison
B
2

There is no individual setting for the Selected Text Foreground properties, it uses the Plain Text Settings for the Foreground in the Options Form, but this will only work for normal text, the Foreground colors for Properties, Comments and other specialty colored text will remain the same, there is no overriding Foreground color that can be used for all items.

Brevet answered 9/7, 2012 at 2:12 Comment(3)
I think you mean that there is one overriding Foreground color, that of 'Plain Text', which is what I had seen. I was just hoping for some trick or setting that I didn't know about. What's funny is that Windows itself lets you pick the different setting for selection, and I set all my system menus up that way. Thanks.Pattison
Note, that was true of Windows XP and earlier, but doesn't seem to set in Windows 7.Pattison
@LanceRoberts What I was trying to say is the Selected Text property is background only. Because of all the different Text colors that Visual Studio uses to impart information, I believe they would have to have seperate SelectedText Foreground color selections for all of them too. And they just used the Plain Text as an example for the Selected Text optionBrevet

© 2022 - 2024 — McMap. All rights reserved.