Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I sort lines of code alphabetically in Visual Studio? [duplicate]

Tags:

Possible Duplicate:
Sort selected text from Visual Studio context menu

I have some lines of code I wish to sort alphabetically, nothing clever.

I wish to just select the lines, and then sort them. (I could copy them into Excel then sort and copy them back, but there must be a better way)

This is the bit of code I am trying to time, in real life it is a lot longer…

sortingColumnOverrides: new Dictionary<Enum, Enum>() {    {Cols.SimulationPrice,Cols.SimulationPriceRange},                    {Cols.BaselineEffectivePrice, Cols.BaselineEffectivePriceRange},                    {Cols.SimulationEffectivePrice, Cols.SimulationEffectivePriceRange},                    {Cols.SimulationCost, Cols.SimulationCostRange},                    {Cols.BaselinePrice,Cols.BaselinePriceRange},                    {Cols.BaselineCost,Cols.BaselineCostRange},                    {Cols.PriceLiftAbs, Cols.SimulationPriceChangeRange},                    {Cols.PriceLiftPct, Cols.SimulationPriceChangePercentRange},                    {Cols.BaselinePricePerUOM, Cols.BaselinePricePerUOMRange},                    {Cols.SimulationPricePerUOM, Cols.SimulationPricePerUOMRange},       //lots more lines like these.... } 

More marks, if there is a easy way to stop the sort at the first ",", but that would just be icing on the cake.

(Other questions in the past of ask about the more complex task of sorting methods by name etc.)

like image 702
Ian Ringrose Avatar asked Oct 26 '11 10:10

Ian Ringrose


People also ask

How do I sort alphabetically in Visual Studio code?

Select my lines of text. Press F9. Keep your eyes on the code, you'll see a change. And now it's in alphabetical order.


1 Answers

You have an add-on for this: http://visualstudiogallery.msdn.microsoft.com/D6678A1F-C700-4532-8C5E-A799D875063D?SRC=VSIDE

like image 74
TheCodeDestroyer Avatar answered Oct 05 '22 00:10

TheCodeDestroyer