Short of cutting and pasting, is there a way to sort the methods in my classes in Visual Studio 2008? I like orderly code.
Resharper will do a good job in a limited way. It depends on how much you want. For example, it wont go and reorder your overrides in an asp.net page based on lifecycle, or anything like that, but it will keep properties, fields, methods and what not clearly grouped
EDIT: By the eway i was refering to auto reordering aka reformatting.
If you are using Resharper, you can change the Type Members Layout template so that it orders your code however you like. See under Resharper>Options>Languages>C#>Type Members Layout. alt text http://www.jetbrains.com/resharper/features/screenshots/40/automatic_member_layout_full.png
You can, for example, put methods with particular attributes first in your file... e.g. methods marked with NUnit's [Setup] and [TearDown] could come before methods marked with [Test] by placing a block like:
<!--Fixture Setup/Teardown-->
<Entry>
<Match>
<And>
<Kind Is="method"/>
<Or>
<HasAttribute CLRName="NUnit.Framework.TestFixtureSetUpAttribute" Inherit="true"/>
<HasAttribute CLRName="NUnit.Framework.TestFixtureTearDownAttribute" Inherit="true"/>
</Or>
</And>
</Match>
</Entry>
before:
<!--Test methods-->
<Entry>
<Match>
<And Weight="100">
<Kind Is="method"/>
<HasAttribute CLRName="NUnit.Framework.TestAttribute" Inherit="false"/>
</And>
</Match>
<Sort>
<Name/>
</Sort>
</Entry>
and then have a catch-all for everything else:
<!--All other members-->
<Entry>
<Sort>
<Name/>
</Sort>
</Entry>
The template system is very powerful and should meet your needs.
ReSharper has Code Reordering functionality and a File Structure view that lets you do drag and drop reordering.
You may find or be able to make a macro to do this, but there is no built in functionality of VS to sort your methods. Some third party productivity tools like Resharper and CodeRush provide some functionality to reorder your code.
This is a free plug-in that does what you are asking: http://www.visualstudiogallery.com/ExtensionDetails.aspx?ExtensionID=800978aa-2aac-4440-8bdf-6d1a76a5c23c
Unfortunately the link is outdated. You can download Regionerate at http://www.rauchy.net/regionerate/docs/2007/05/download.html