Solvedomnisharp vscode remove unused usings

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-preview2-003131)

Product Information:
 Version:            1.0.0-preview2-003131
 Commit SHA-1 hash:  635cf40e58

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64

VS Code version: 1.9.1
C# Extension version: 1.7.0

Steps to reproduce

Search in Command Palette for "Remove Unused Usings" or "Remove Unnecessary Usings" command.

Expected behavior

Option to "Remove Unused Usings" or "Remove Unncessary Usings" is available in Command Palette. Executing the command will remove all unnecessary usings from the active .cs file.

Actual behavior

No feature exists.

Expecting a feature like this (from VS 2015):

remove-unused-usings

This issue seems very similar to #788 but I think removing unused usings is a much different feature from sorting. Removing usings prevents code warnings, shortens code, etc.

18 Answers

✔️Accepted Answer

Bump!... This reasonably basic capability is a big miss on Visual Studio Code. I'm so used to having this from VS2017 and before and when you have loads of .cs files and many have a lot of using statements there is no way to cull the list without a majorly time-consuming effort.

Please can we have the capability to remove unused using statements - either through keyboard shortcut or through document formatting.

Other Answers:

it is already implemented.

press ctrl+p (cmd+P on a Mac), select the option OmniSharp: Fix all occurrences of a code issue within a project (there are additional options for document/solution level too). All fixable issues from the given scope should show up - so select CS8019: Unnecessary using directive.

Bildschirmaufnahme 2021-01-19 um 22 25 44

is there any news on this? jesus i dont see how this is still not implemented?

Any update on this?

Any update on this? I would really love to have this available... It is so nice in VS to be able to run a keystroke and it remove & sort my usings.

More Issues: