更新请参阅@JakubZawiślak对VScode 1.12+的回答
老答案
Visual Studio Code调用此选项突出显示,不幸的是,我认为当前颜色不可定制。主题可以控制“选择”颜色,但“选择突出显示”颜色是硬编码的。
查看此问题,跟踪可能的解决方案:https://github.com/Microsoft/vscode/issues/1636
(作为旁注,您可以使用editor.selectionHighlight
设置切换此功能或/关闭。)
将以下行添加到settings.json文件中的“Editor:Token Color Customizations”设置中。
"workbench.colorCustomizations": {
"editor.selectionBackground": "#135564",
"editor.selectionHighlightBackground": "#135564"
},
有关更多选项,请参阅Theme Color Reference
如果有人发现这个,并像我一样,无法让上述配置工作尝试这样做。
一定要用你想看的颜色替换#。
"workbench.colorCustomizations": {
"editor.lineHighlightBackground": "#<color1>",
"editor.selectionBackground": "#<color2>",
"editor.wordHighlightBackground": "#<color3>",
"editorCursor.foreground": "#<color4>"
},
我对上面的配置有所了解。
editor.lineHighlightBackground - 当你点击一条线时,这是线条背景的颜色。
“editor.selectionBackground” - 这是缓冲区中其他位置匹配选择的背景。想象一个名为foo的变量,它在整个文件中使用。然后,您突出显示该文本,页面上的所有其他foos将是这种颜色。
“editor.wordHighlightBackground” - 如果单击时的默认突出显示单词不生效,则这是所选文本的颜色。我只看到这个值有所不同,如果你点击一个不自动选择的单词。
editorCursor.foreground - 这是光标的颜色。
上面的答案涵盖了Selected text
和areas with same content as selection
,但他们错过了Current Search Match
和Other Search Matches
- 它们有完全相同的问题。
"workbench.colorCustomizations": {
"editor.findMatchBackground": "#00cc44a8", //Current SEARCH MATCH
"editor.findMatchHighlightBackground": "#ff7b00a1" //Other SEARCH MATCHES
}
{ "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", //Currently SELECTED text "editor.selectionHighlightBackground": "#ff00005b", //Same content as selection "editor.findMatchBackground": "#00cc44a8", //Current SEARCH MATCH "editor.findMatchHighlightBackground": "#ff7b00a1" //Other SEARCH MATCHES } }
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
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
你可以用你最喜欢的颜色改变它:
脚步
打开设置后,您将更新右侧栏中的设置,将此代码复制并粘贴到主括号{ ... }
中
"workbench.colorCustomizations": {
"editor.selectionBackground": "#f00", // red color hexadecimal code
"editor.selectionHighlightBackground": "#fff" // white hex code
},
如果有人发现自己正在阅读@FujiRoyale的答案,因为其他人都没有工作,并且想知道为什么他/她也没有工作,但是因为最近想知道为什么,我跟着他们的回答,并且(与v1的v1.18) )这作为user settings
设置:
{
// Is git enabled
"git.enabled": true,
// Path to the git executable
"git.path": "C:\\Users\\t606964\\AppData\\Local\\Programs\\Git\\mingw64\\bin\\git.exe",
"workbench.startupEditor": "newUntitledFile",
// other settings
//
"editor.fontSize": 12,
"editor.tabSize": 2,
"git.confirmSync": false,
"workbench.colorTheme": "Monokai",
"editor.fontWeight": "bold",
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"workbench.iconTheme": "vscode-icons",
"explorer.confirmDelete": false,
"files.autoSave": "off",
"workbench.colorCustomizations": {
"editor.lineHighlightBackground": "#f00",
"editor.selectionBackground": "#0f0",
"editor.wordHighlightBackground": "#00f",
"editorCursor.foreground": "#ff0"
}
}
请注意缩进和逗号,并从他们的答案中删除双引号(我必须使用它才能使其正确,这在答案中并不清楚)。应该没有必要重新启动vscode,但它可能值得去File > Autosave
,看看你是否开始获得主要颜色突出显示。然后为您的亮点选择更好的颜色。
您也可以通过粘贴在workspace settings
中完成这项工作
"workbench.colorCustomizations": {
"editor.lineHighlightBackground": "#f00",
"editor.selectionBackground": "#0f0",
"editor.wordHighlightBackground": "#00f",
"editorCursor.foreground": "#ff0"
}
在右侧设置窗格中的现有{}
之间。
更改步骤突出显示默认颜色
Ctrl+k,t
。