Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 73787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:15:22+00:00 2026-05-10T20:15:22+00:00

I know you can do it file by file. Is there any way to

  • 0

I know you can do it file by file.

Is there any way to do this in one step for all files in a project?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:15:23+00:00Added an answer on May 10, 2026 at 8:15 pm

    Do you mean using statements? First, note that they generally do no harm other that take space. Tools like ReSharper offer automated tricks to do this, however: there was a link in the VS feed a little while ago; it boils down to:

    • go to Tools -> Macros -> Macros IDE…
    • in the Project Explorer, Add -> Add Module… (put in a name – I’ve used OrganiseUsings)
    • paste over with the code below
    • File -> Save MyMacros, exit

    Now if you right-click on the toolbar and Customize… – you should be able to find MyMacros.OrganiseUsings.RemoveAndSortAll – drag this somewhere handy (maybe the Tools menu; you might also want to change the name after placing it).

    You can now use this option to run the Remove and Sort command for an entire solution. A big time-saver.

    ==== code ====

    Imports System Imports EnvDTE Imports EnvDTE80 Imports EnvDTE90 Imports System.Diagnostics  Public Module OrganiseUsings      Public Sub RemoveAndSortAll()         On Error Resume Next         Dim sol As Solution = DTE.Solution          For i As Integer = 1 To sol.Projects.Count                 Dim proj As Project = sol.Projects.Item(i)                 For j As Integer = 1 To proj.ProjectItems.Count                     RemoveAndSortSome(proj.ProjectItems.Item(j))                 Next             Next         End Sub          Private Sub RemoveAndSortSome(ByVal projectItem As ProjectItem)         On Error Resume Next         If projectItem.Kind = Constants.vsProjectItemKindPhysicalFile Then                 If projectItem.Name.LastIndexOf('.cs') = projectItem.Name.Length - 3 Then                 Dim window As Window = projectItem.Open(Constants.vsViewKindCode)                  window.Activate()                  projectItem.Document.DTE.ExecuteCommand('Edit.RemoveAndSort')                  window.Close(vsSaveChanges.vsSaveChangesYes)             End If             End If              For i As Integer = 1 To projectItem.ProjectItems.Count                 RemoveAndSortSome(projectItem.ProjectItems.Item(i))             Next     End Sub     End Module 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to get input from a file one number at a
Is there any possible way when in one file - please note, just one
I know I can add a icon to the Resources.resx file of a project
Is there any way that I can link a keyword in a TextView to
I know I can redirect awk's print output to another file from within a
Do you know how can I call an ASP.NET .dll file from a PHP
I need to know if I can create a file in a specific folder,
I know the file needs to be where the getClass().getResource(filename) can find it, but
I know that with mysql you can write SQL statements into a .sql file
I want to know which *.config file the ConfigurationManager is using. How can I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.