Search code examples
actionscript-3formattingdeclarationcode-formattingalphabetical

How to auto-format AS3 variable declarations in alphabetical order?


While coding, I wondered if a plugin exists that I could highlight a series of variable declarations, hit some special keyboard shortcut and BAM! They would appear in alphabetical order.

Is there anything that does this in Flash Builder? Or FlashDevelop even?

So it would go from this:

private var _value:Number;
private var _helloWorld:String;
private var _foobar:Boolean;

To this:

private var _foobar:Boolean;
private var _helloWorld:String;
private var _value:Number;

Solution

  • FlexFormatter is a plugin for Flash Builder and allows you to do this. You can enable it in the plugin's options ("AS rearranging"). Afterwards you can select the lines of code and press Ctrl + Shift + F to format the selected lines.

    You can install the plugin by adding the following update site to your Flash Builder (Eclipse):

    http://flexformatter.googlecode.com/svn/trunk/FlexFormatter/FlexPrettyPrintCommandUpdateSite/