Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unused usings #1245

Closed
kindohm opened this issue Feb 16, 2017 · 17 comments
Closed

remove unused usings #1245

kindohm opened this issue Feb 16, 2017 · 17 comments

Comments

@kindohm
Copy link

kindohm commented Feb 16, 2017

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.

@DustinCampbell
Copy link
Member

This is really a duplicate of #1179.

@msivers
Copy link

msivers commented Nov 4, 2018

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.

@CrossBound
Copy link

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.

@memark
Copy link

memark commented Sep 14, 2019

Any update on this?

@DmitriyBobrovskiy
Copy link

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

@marcusturewicz
Copy link

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

@DmitriyBobrovskiy
Copy link

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

@savpek
Copy link
Contributor

savpek commented Dec 1, 2019

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

@richarddavenport
Copy link

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

@filipw
Copy link
Contributor

filipw commented Feb 13, 2020

should not be long

@FloatingSunfish
Copy link

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

@johmarjac
Copy link

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

@Esildor
Copy link

Esildor commented Jan 19, 2021

lololol at this still not being implemented yet. I'm over here living in 2021 bro

@filipw
Copy link
Contributor

filipw commented Jan 19, 2021

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

@JoeRobich
Copy link
Member

Closing as this has been implemented.

@richarddavenport
Copy link

@filipw Thanks for the update. One clarifying question, do you know if this is possible when formatting? Thanks!

@filipw
Copy link
Contributor

filipw commented Jan 20, 2021

unfortunately not at the moment. there is only an option to sort the usings on formatting (https://github.com/OmniSharp/omnisharp-roslyn/blob/master/CHANGELOG.md#13410---2020-01-27)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests