NArrange - organize your code effortlessly

The second thing I do(this is the first) with a new install of Visual Studio is I head over to and download the latest version of NArrange.  NArrange is an open source .NET code organizer/formatter/beautifier.

After downloading and installing(and noting the folder where the exe is installed) the NArrange setup.msi, I go into my new install of Visual Studio and click on Tools and select External Tools.

Select External Tools

This opens the External Tools dialogue.  Click Add and in the Title field I put "NArrange" and beside the Command field I click the ...(browse) button and go to the folder where I installed NArrange and select the narrange-console.exe file.  For Arguments I like to only do one file at a time as I'm working so I set it to $(ItemFileName)$(ItemExt) /b and the Initial directory to $(ItemDir).  The /b causes a back up of the file before NArrange makes it's changes, this is necessary to do the restore command below. Then I check the Use Output window checkbox, so that I can see any issues that come up when NArrange runs, and click Apply.

NArrange Command

Next I create a restore command. I click the Add button and in the Title field put "NArrangeRestore" and for the Command field I do the same as before.  For Arguments I do the same as before except put /r for restore instead of /b. The /r will make NArrange restore the file back to what it was before the last time it ran. Set the Initial directory to $(ItemDir), like the first command. Then I check the Use Output window checkbox and click Apply.

NArrange Restore Command

NArrange is now ready for use.  When I have a file I would like to organize I just open it and then go to Tools and select NArrange.

NArrange Run

NArrange then backs up the file and reorganizes it, putting all the Fields in one place and orders them alphabetically and so on for Methods, and Delegates etc, and even sorts the Imports.

NArrange Done