question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

remove unused usings

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:30
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

14reactions
filipwcommented, 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

13reactions
msiverscommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Quick Tip - Remove Unused Using References in Visual Studio
First is putting your cursor on one of the grayed out lines and clicking the light bulb, then clicking Remove Unnecessary Usings.
Read more >
Clean Up & Sort Unused .NET Using Statements in Visual ...
Clean Up & Sort Unused .NET Using Statements in Visual Studio · The easiest way to find anything in Visual Studio is click...
Read more >
Remove unused directives (or "usings") with Code Cleanup ...
Hey there,. I'd like to let Resharper cleanup unused usings/directives from files, during Code cleanup, on file saving.
Read more >
Remove and Sort – Namespaces using Shortcut in Visual Studio
From Tools > Option , navigate to Keyboard tab. Search for “Edit.RemoveAndSort” which command will to both remove unused usings and sort the...
Read more >
Remove unused references - Visual Studio (Windows)
How-to · Right click on a project name or dependencies node in Solution Explorer. · Select Remove Unused References. Remove Unused References ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found