Omnisharp-vscode: remove unused usings

Created on 16 Feb 2017  路  12Comments  路  Source: OmniSharp/omnisharp-vscode

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.

Editor-Unnecessary usings Feature Request Triaged

Most helpful comment

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.

All 12 comments

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.

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.

Any update on this?

Any updates, guys? We really would like to see this feature in VSCode.

How would one go about implementing this? Happy to have a crack, given some direction.

How would one go about implementing this? Happy to have a crack, given some direction.

Well, there is already implemented some kind of this functionality in vscode. When you go to usings and press Ctrl+. at the line with unused using, you would see suggestion to remove unnecessary usings.
Furthermore there is feature of determining usings which are not used (they are not so bright as those which are used).
So, probably there is some way of combining these two features to make it work.
If I know it a bit deeper, I'd implement it by myself.
image

I think this can be handled by https://github.com/OmniSharp/omnisharp-roslyn/pull/1581 once it's ready, it might be good idea to add shortcut key support for "Fix all auto fixable issues at current document" (?)

@savpek That's a fantastic idea. Do you know if/when OmniSharp/omnisharp-roslyn#1581 is going to be shipped?

should not be long

@filipw Any updates on this issue?
Having an option to remove unused usings upon Save would be a very useful thing to have.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mattwoberts picture mattwoberts  路  3Comments

hamhub7 picture hamhub7  路  3Comments

kiminuo picture kiminuo  路  3Comments

tstivers1990 picture tstivers1990  路  3Comments

jrmcdona picture jrmcdona  路  3Comments