Sublime Forum

Changing foreground color of (mouse) selected region

#1

In some schemes, the highlighting (background) color when selecting a region with a mouse is very similar to that of the foreground text, making such text impossible to read. By contrast, when searching for a given string, the result is highlighted in such a way that both the foreground and background colors are set in high contrast.

Is is possible to have a theme defined so that the highlighted region (when selected by a mouse) will be similar to that resulting from a search?

0 Likes

#2

Alternatively, if I could find a way to assign a key to do the following:

  • after selecting some text do:
  1. ctrl-e
  2. mouse-click before the text selection in main window (to give it focus again)
  3. F3
    It would accomplish what I’m hoping to do. I gather that macros do not deal with mouse clicks…
0 Likes

#3

Believe you can edit your color scheme file to change the mouse selected region. One of the keys in that file is “selection” followed by a color specified in hex.

0 Likes

#4

Yes, I have already mentioned that in my first post. The problem I have is that any decent looking highlighting color ends up being too close to the foreground color of some scope/keyword/etc. When selecting a word through a search, the foreground color gets altered as well, thereby ensuring proper contrast.

0 Likes

#5

Open your theme files (or create your own) and find this string:

selection
#ba5000

Just below add this:

selectionForeground
#FFFFFF

Tested in Sublime Text 3.

0 Likes

#6

selectionForeground worked as well for SublimeText 2. Thanks! :smiley:

0 Likes

#7

I’m trying to do something similar i.e. changing the foreground color for the selected text but only for the comments. I’ve tried to edit the comment section from Solorized (Dark).thTheme like this:

<dict> <key>name</key> <string>Comment</string> <key>scope</key> <string>comment</string> <key>settings</key> <dict> <key>fontStyle</key> <string></string> <key>foreground</key> <string>#586E75</string> <key>selectionForeground</key> <string>#2AA198</string> </dict> </dict>

But the selectionForeground appears to be ignored in this case. I’m using Sublime Text 3.

Is there any way to achieve this?

0 Likes

#8

“selection_foreground”: “var(white)”
This worked for me in SublimeText3 inside colour scheme setting

0 Likes