Anders Lindén
Anders Lindén

Reputation: 7323

Dim out unused C++ variables in VS Code?

I have setup VS Code with the line

"editor.showUnused": true

However, code still looks like

code that does not dim out unused variable "foobar"

I added *foobar myself and it seems to not be displayed in a dimmed out fashion.

Why not?

If VS Code does not have C/C++ support of showing unused variables in the editor with an alternate color, is there some other IDE in linux that has?

Upvotes: 2

Views: 5092

Answers (2)

starball
starball

Reputation: 52159

Assuming you are using the cpptools extension...

For problem underlining (squiggly underlines), you can configure a build task and set the problem matcher property to some appropriate value. See also Unused variables are not highlighted in the editor #6588.

For dimmed text, at the time of this writing, there is an open feature-request issue ticket: Dimming of Unused Variables #10490. Give it a thumbs up to increase its prioritization level, and subscribe to it to get notified about discussion and progress. Please avoid making noisy comments there like "+1" / "bump".

Upvotes: 0

Matt Bierner
Matt Bierner

Reputation: 65603

Language extensions are responsible for determining which variables are unused. Here, this would be the C++ extension. This is because detecting unused variable requires understanding of the structure and semantics of your program

I do not believe that that the C++ extension currently supports fading out unused variables. Please file a feature request if you would like to see this supported

Upvotes: 2

Related Questions