VS代码:如何更改所选文本和选择/单词匹配的高亮显示?

Dav*_*itt 15 editor visual-studio-code

视觉混淆:"选定文本"和"选择匹配"突出显示颜色

作为每日VS Code用户,我发现了一个较早的封闭问题(选择和选择匹配突出显示颜色#1636) - 即如果您实际选择了一些突出显示的文本,但突出显示的颜色几乎与用于匹配代码的突出显示无法区分或同一个词.

本地用户设置 - 如CSS覆盖?

如果系统范围的高亮颜色(在系统范围内选择任何文本时)无法移植到VS代码,我需要一种方法来编辑它.也许在主题的CSS或 - 最好 - 在用户生成的'覆盖css'文件或某些东西(如VS Code的用户设置)中.这是在管道中吗?如果没有,有人有修复吗?

ATM改变所选文本的高亮颜色似乎是不可能的.我正在使用'黑暗',但无论哪个主题,问题都是一样的.

Mar*_*ark 14

现在可以对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.
Run Code Online (Sandbox Code Playgroud)

请参阅大约v1.13提供的vscode主题颜色选项.

  • 谢谢你,有用的链接。我正在使用 1.14.2 - 值得指出(大概是因为设置在主题中)这些不在“设置”中。所以你必须在你的用户设置中添加一个新的 `"workbench.colorCustomizations":` 块。 (4认同)

css*_*hus 12

要填写几个缺少的步骤:

  1. 打开settings.json文件(有关此文件的位置,请参见下文)

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

  3. 粘贴:

    “ workbench.colorCustomizations”:{
        “ editor.selectionBackground”:“#e788ff”,//当前选择的文本
        “ editor.selectionHighlightBackground”:“#ff0000”,//与选择内容相同
        “ editor.findMatchBackground”:“#00cc44a8”,//当前的搜索匹配
        “ editor.findMatchHighlightBackground”:“#ff7b00a1” //其他搜索匹配
    }

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

    {
        “ git.enableSmartCommit”:是的,
        “ git.autofetch”:是的,
        “ breadcrumbs.enabled”:是的,
        “ git.confirmSync”:否,
        “ explorer.confirmDelete”:否,
        “ code-runner.saveFileBeforeRun”:是,
        “ code-runner.saveAllFilesBeforeRun”:是,
        “ workbench.activityBar.visible”:是,
        “ files.trimTrailingWhitespace”:是的,
        “ telemetry.enableTelemetry”:否,
        “ workbench.colorCustomizations”:{
            “ editor.selectionBackground”:“#e788ff7c”,//当前选中的文本
            “ editor.selectionHighlightBackground”:“#ff00005b”,//内容与选择相同
            “ editor.findMatchBackground”:“#00cc44a8”,//当前的搜索匹配
            “ editor.findMatchHighlightBackground”:“#ff7b00a1” //其他搜索匹配
        }
    }


在哪里可以找到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
Run Code Online (Sandbox Code Playgroud)

ALTERNATE方法打开settings.json文件:

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

  2. 工作台

  3. 设定编辑器

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

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

  6. 单击右侧的链接: 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


Jai*_*der 7

我正在使用 sarah.drasner 的 Night Owl 主题,对于 VSCode,默认情况下,文本选择将被单词选择压倒,如果我真的做出选择,我总是会感到困惑?。

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

"workbench.colorCustomizations": {
    "editor.wordHighlightBackground": "#0066ff2a",
    "editor.wordHighlightStrongBackground": "#0066ff2a",
}
Run Code Online (Sandbox Code Playgroud)

有人认为我想澄清您需要 2 个值(如 rgba)=

  1. RGB 颜色,例如 在此处输入图片说明
      +
  2. 透明度(00 到 FF),例如2a

前: 在此处输入图片说明

后: 在此处输入图片说明

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