Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There is also <strong><a href="http://blogs.msdn.com/b/djpark/archive/2008/08/16/organize-usings-across-your-entire-solution.aspx" rel="nofollow">another way I found here</a></strong>, using Macros.</p> <blockquote> <p>Step 1: Create a new macro in Visual Studio through the Tools | Macros menu.</p> <p>Step 2: Paste the code below into the Module and save it</p> </blockquote> <pre><code>Public Module Module1 Sub OrganizeSolution() Dim sol As Solution = DTE.Solution For i As Integer = 1 To sol.Projects.Count OrganizeProject(sol.Projects.Item(i)) Next End Sub Private Sub OrganizeProject(ByVal proj As Project) For i As Integer = 1 To proj.ProjectItems.Count OrganizeProjectItem(proj.ProjectItems.Item(i)) Next End Sub Private Sub OrganizeProjectItem(ByVal projectItem As ProjectItem) Dim fileIsOpen As Boolean = False If projectItem.Kind = Constants.vsProjectItemKindPhysicalFile Then 'If this is a c# file If projectItem.Name.LastIndexOf(".cs") = projectItem.Name.Length - 3 Then 'Set flag to true if file is already open fileIsOpen = projectItem.IsOpen Dim window As Window = projectItem.Open(Constants.vsViewKindCode) window.Activate() projectItem.Document.DTE.ExecuteCommand("Edit.RemoveAndSort") 'Only close the file if it was not already open If Not fileIsOpen Then window.Close(vsSaveChanges.vsSaveChangesYes) End If End If End If 'Be sure to apply RemoveAndSort on all of the ProjectItems. If Not projectItem.ProjectItems Is Nothing Then For i As Integer = 1 To projectItem.ProjectItems.Count OrganizeProjectItem(projectItem.ProjectItems.Item(i)) Next End If 'Apply RemoveAndSort on a SubProject if it exists. If Not projectItem.SubProject Is Nothing Then OrganizeProject(projectItem.SubProject) End If End Sub End Module </code></pre> <blockquote> <p>Step 3: Run the macro on any solution that you'd like and there you have it! Enjoy :)</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload