Flex Code Folding In Amethyst
There are certain things I just couldn’t live without in a code editor. Code colouring and auto code-formatting are two of them. Amethyst has both those features by the ton (see ActionScript Code Formatting and A Brief Guide To Amethyst). A third thing that I find incredibly useful is code collapsing (also known as ‘code folding’ or ‘code outlining’). And yes, Amethyst does that too.
Every block of ActionScript code delimited by curly brackets can be folded away by clicking on the little ‘+’ symbol in the margin. This can even be done on ActionScript code in MXML files - and believe me, providing the same level of coding in ‘pure’ ActionScript (.as) files and in ‘mixed’ ActionScript/MXML (.mxml) files is by no means as trivial a task as you may think!
We provide code folding for MXML too. When you have paired tags - say an opening
<mx:Canvas ... > tag, some nested controls and then a closing
</mx:Canvas> tag, you can fold away the Canvas tags and all their contents and unfold them again later on. When working in MXML you may also collapse the entire Script area to hide and show your ActionScript code.
Code collapsing is great when you need to hide blocks of code that you aren’t working on in order to concentrate on the code you are working on. Incidentally, you aren’t restricted to folding by ‘syntax’. You can also define arbitrary regions. Just write a line comment like this to mark the start of a collapsible region:
To mark the end of the region, enter this:
Optionally you can name regions for clarity:
//region Time Lord Regeneration Routines
Bear in mind that, at the time of writing, we have only just released the second beta of Amethyst and, as with all other features of the software, the code folding will be improved and enhanced over time. All the same, even in its beta state, this is a feature that I personally use all the time when I am coding. You might want to give it a try...