VS代码如何将未使用的变量显示为红色

Sim*_*ton 1 visual-studio-code vscode-settings

我的编辑器设置为未使用的导入和变量启用了变灰: "editor.showUnused": true

但是,如何更改它,使该行具有红色背景而不是变灰呢?

这是一个Javascript文件。

vscode中未使用的变量导入

Yuv*_*til 11

第 1 步:打开Settings页面。

  • 点击File。它将打开文件菜单。
  • 单击/悬停在Preferences(在 MacOS 中,Preferences选项移至Code选项卡下)。它将打开首选项菜单。
  • 单击Settings选项。它将打开设置页面。

第 2 步:打开settings.json.

  • 在设置页面上,单击Appearance选项卡(在最新的 VS Code 中,Appearance选项卡移至Workbench选项卡下方)。它将显示Appearance选项。
  • 在里面检查Color Customizations选项。它会有链接Edit in settings.json。单击该链接。
  • 它将打开settings.json

步骤 3:更新设置。

  • 用于editorUnnecessaryCode.border更新不必要代码的边框颜色。
"workbench.colorCustomizations": {
   "editorUnnecessaryCode.border": "#ff0000"
 }
Run Code Online (Sandbox Code Playgroud)


Jef*_*eff 5

While messing around in the Visual Studio Code (v1.38.0) settings.json for a colorblind coworker, I found success with this setting:

"workbench.colorCustomizations": {
  "editorUnnecessaryCode.border": "#dd7aab"
},
Run Code Online (Sandbox Code Playgroud)

The ^ setting does not exactly solve your desire for a red background, but it does provide an alternative that will help accentuate the unused item. This is what it looks like for us:

在此处输入图片说明

在此处输入图片说明

FYI: I had failures while playing around with the following settings:

editorUnnecessary.foreground
editorUnnecessaryCode.foreground

"workbench.colorCustomizations": {
  "editorUnnecessary.foreground": "#dd7aab"
}

"workbench.colorCustomizations": {
  "editorUnnecessaryCode.foreground": "#dd7aab"
}
Run Code Online (Sandbox Code Playgroud)

The VSCode team needs to finalize the plan and documentation for the theming of the unused (unnecessary) code.

  • 这对 2021 年的我有用 (2认同)

小智 2

据我所知,这个选项似乎从1.25版本中被删除了。

请参考:改进颜色名称editorUnnecessary.foreground