如何更改所选文本和 selection/word 匹配项的突出显示?

How to change the highlights for selected text and selection/word matches?

视觉混乱:'selected text'和'selection matches'高亮颜色

作为 VS Code 的日常用户,我发现了一个较早关闭的问题 (Selection and selection matches highlight color #1636) 关于此问题 - 即如果您 实际上 select 某些文本会突出显示, 但突出显示的颜色与用于匹配代码或相同单词的突出显示几乎没有区别。

像本地用户设置一样 CSS 覆盖?

如果系统范围内的高亮颜色(当 selecting any 系统范围内的文本时)不能移植到 VS Code,我需要一种方法来编辑它。也许在主题的 CSS 或 - 最好 - 在用户生成的 'override css' 文件或其他东西(如 VS Code 的用户设置)中。这是在筹备中吗?如果没有,有人有解决办法吗?

ATM 更改 selected 文本的突出显示颜色似乎是不可能的。我正在使用 'Dark',但无论使用哪个主题,问题都是一样的。

现在可以对 vscode 进行许多颜色自定义,包括选择选项:

editor.selectionBackground: Color of the editor selection.
editor.selectionHighlightBackground: Color for regions with the same content as the selection.
editor.inactiveSelectionBackground: Color of the selection in an inactive editor.

请参阅 vscode theme color options 我相信可以从大约 v1.13 获得。

要填写几个缺失的步骤:

  1. 打开 settings.json 文件 (此文件的位置见下文)

  2. 在最后一个条目中添加一个逗号(在右大括号 } 之前)

  3. 粘贴:

    "workbench.colorCustomizations": {
        "editor.selectionBackground": "#e788ff", //Current SELECTED text
        "editor.selectionHighlightBackground": "#ff0000", //same content as the selection
        "editor.findMatchBackground": "#00cc44a8", //Current SEARCH MATCH
        "editor.findMatchHighlightBackground": "#ff7b00a1" //Other SEARCH MATCHES
    }

典型设置文件示例,post mod:

    {
        "git.enableSmartCommit": true,
        "git.autofetch": true,
        "breadcrumbs.enabled": true,
        "git.confirmSync": false,
        "explorer.confirmDelete": false,
        "code-runner.saveFileBeforeRun": true,
        "code-runner.saveAllFilesBeforeRun": true,
        "workbench.activityBar.visible": true,
        "files.trimTrailingWhitespace": true,
        "telemetry.enableTelemetry": false,
        "workbench.colorCustomizations": {
            "editor.selectionBackground": "#e788ff7c", //Current selected text
            "editor.selectionHighlightBackground": "#ff00005b", //Same content as selection
            "editor.findMatchBackground": "#00cc44a8", //Current SEARCH MATCH
            "editor.findMatchHighlightBackground": "#ff7b00a1" //Other SEARCH MATCHES
        }
    }


在哪里可以找到 settings.json 文件:

Depending on your platform, the user settings file is located here:

Windows %APPDATA%\Code\User\settings.json
macOS $HOME/Library/Application Support/Code/User/settings.json
Linux $HOME/.config/Code/User/settings.json

打开 settings.json 文件的备用方法:

  1. Ctrl + ,(逗号)打开设置

  2. Workbench

  3. 设置编辑器

  4. 在顶部的搜索框中,粘贴workbench.colorCustomizations

  5. 在左侧,单击 Workbench,然后单击 Appearance

  6. 点击右边的link:Edit in settings.json

参考文献:

https://code.visualstudio.com/api/references/theme-color#editor-colors

https://code.visualstudio.com/docs/getstarted/themes#_customize-a-color-theme

https://code.visualstudio.com/docs/getstarted/settings

我使用 sarah.drasner 的 Night Owl 主题,用于 VSCode,默认情况下,文本选择会被单词选择压倒,我把所有的都弄糊涂了时间如果我真的做出选择?

测试各种变量...对我有用的是单词高亮背景(你可以试试边框)。

"workbench.colorCustomizations": {
    "editor.wordHighlightBackground": "#0066ff2a",
    "editor.wordHighlightStrongBackground": "#0066ff2a",
}

我想澄清一下,您需要 2 个值(如 rgba)=

  1. RGB 颜色,例如
      +
  2. 透明度(00 到 FF),例如2a

之前:

之后:

更多信息:https://code.visualstudio.com/api/references/theme-color#editor-colors

关键答案!

您想要的设置:

这两个设置名称:

是这两种颜色吗:

每一项是什么?巨额小费!

settings.json 编辑器中有一个非常有用的鼠标悬停工具提示:

请注意,它详细解释了该设置的作用!

在当前 (2020) VSCode 如何编辑这些?

VSCode 的一大乐趣就是偏好设置如此简单。 (在 VS 中,这是一场噩梦。)

点击设置,然后点击这个: