Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change color of unused variable/imports

VS Code now greys out unused variable/imports. Is there a way to change the color? As the grey conflicts with the theme I am using.

The theme I am using (Blueprint) uses the same color for object keys.

like image 469
Musa Avatar asked Jun 19 '18 14:06

Musa


People also ask

How do I change the color of a variable in Vscode?

In Visual Studio Code, use Ctrl + Shift + P and type settings. json to the field that shows up. After you type it, it should give you the settings.

How do I get rid of unused imports in Vscode?

please use the default key combination below. CTRL + ALT + O —> to remove the unused imports in windows. However, you can also change the keymap of “Optimize Imports” in settings.


1 Answers

There are two options:

enter image description here

and you can change it via Code > Preferences > Settings > settings.json like:

"workbench.colorCustomizations": {
  "editorUnnecessaryCode.border": "#0000ff"
}

but it does not look well. If you want to achieve a satisfying solution, you can add a new css class into workbench.desktop.main.css (that's a hack!):

.monaco-editor.showUnused .squiggly-inline-unnecessary {
  opacity: 0.8;
  border-bottom: 1px dotted red;
  color: red;
}

It would then look like (Input and router are unused):

Coloring unused variables

Unfortunately, you have to look for the file here: /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.css; it is a part of the official release:

enter image description here

VSCode shows you a notification after your modification that your installation may be corrupt but you can ignore this message.

like image 153
Lonely Avatar answered Oct 02 '22 23:10

Lonely