当前位置:  开发笔记 > 编程语言 > 正文

在Visual Studio代码中更改突出显示文本颜色

如何解决《在VisualStudio代码中更改突出显示文本颜色》经验,为你挑选了5个好方法。

现在,它是一个微弱的灰色覆盖层,很难看到.有什么方法可以改变默认颜色?

在此输入图像描述



1> Jakub Zawiśl..:
"workbench.colorCustomizations": {
    "editor.selectionBackground": "#135564",
    "editor.selectionHighlightBackground": "#135564"
},

有关更多选项,请参阅主题颜色参考


这个答案应该标记为解决方案.
有什么办法可以改变文字颜色?否则,您必须找到一种与配色方案中的每种颜色配对时都能保持可读性的背景色。这是使我无法使用VS Code的两个问题之一...
@BrunoBEly如果你打开`"workbench.colorCustomizations":{}`然后开始输入``editor.selection`,自动完成菜单会建议所有可能的键及其解释,包括选择前景.

2> cssyphus..:

上面的答案涵盖了Selected textareas with same content as selection,但是错过了Current Search MatchOther Search Matches- 具有同样的问题

"workbench.colorCustomizations": {
    "editor.findMatchBackground": "#00cc44a8", //Current SEARCH MATCH
    "editor.findMatchHighlightBackground": "#ff7b00a1" //Other SEARCH MATCHES
}

请注意,在使用“更改所有出现次数” CtrlF2 (一个超级有用的命令,它会 智能地 选择所有出现的字符串,将光标置于每个位置进行多实例编辑)时,上述设置也会影响颜色。


一个典型的设置文件示例,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”:否,
        “ scm.providers.visible”:0,// 0允许手动调整源代码控制面板的大小
        “ 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

ALTERNATE方法打开settings.json文件:

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

    工作台

    设定编辑器

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

    在左侧,单击Workbench,然后Appearance

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



3> FujiRoyale..:

If anyone finds this and, like me, was unable to get the above config working try doing this.

    go to file > Preferences > settings

    type in the search Editor token color customizations

    under the Editor token color customizations header

    click on edit in settings.json

    on the right hand column select user settings

    paste this into the json object

Be sure to replace the #'s with colors you want to see.

"workbench.colorCustomizations": {
    "editor.lineHighlightBackground": "#",
    "editor.selectionBackground": "#",
    "editor.wordHighlightBackground": "#",
    "editorCursor.foreground": "#"
},

My understanding of the above config.

editor.lineHighlightBackground - when you click on a line this is the color the line background will be.

"editor.selectionBackground" - This is the background of matched selections elsewhere in the buffer. Think of a variable named foo and it's used all over a file. You then highlight that text and all the other foos on the page will be this color.

"editor.wordHighlightBackground" - This is the color of selected text if the default highlight word on click does not take effect. I've only seen this value make a difference if you click on a word that does not auto-select.

editorCursor.foreground - this is the color of your cursor.


这应该是答案。这些是VSCode 1.3+版中使用的设置

4> Matt Bierner..:

更新 请参阅@JakubZawiślak对VScode 1.12+的回答


老答案

Visual Studio Code调用此选项突出显示,不幸的是,我认为当前颜色不可定制.主题可以控制"选择"颜色,但"选择突出显示"颜色是硬编码的.

请参阅此问题,跟踪可能的解决方案:https://github.com/Microsoft/vscode/issues/1636

(作为旁注,您可以使用editor.selectionHighlight设置切换此功能或/关闭.)


***已过时***。
更新以参考JakubZawiślak对现代版VSCode的回答

5> 小智..:

正如我测试过的那样,设置边框颜色比设置背景颜色更容易阅读,这是Sublime Text的作用。

例如,将这些行添加到settings.json

"workbench.colorCustomizations": {
    "editor.selectionHighlightBorder": "#FFFA",
},

所选单词将显示为:

推荐阅读
女女的家_747
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有