This is the first of my Studio 8 'Features of the Day', I'll be posting these each weekday until Studio 8 ships, and the first is on Dreamweaver's long-awaited new feature- Code Collapse.
When working in complex code blocks, have you ever wished you could hide sections you aren't working on to make navigation a little easier? With Dreamweaver 8's code collapse feature, you can collapse any tag, function or block- saving valuable scrolling time and most importantly... your sanity.
Using Code Collapse is a snap- just select any fragment of code in Code view, and you'll see two 'triangle' markers in the gutter by the line numbers- just click one of them and your entire section rolls up out of view quickly, saving precious real-estate. If you're not a mouse-clicker, the keyboard shortcuts Control-Shift-C (Win) or Command-Shift-C (Mac) collapse your selection, and Control-Shift-E (Win) or Command-Shift-E (Mac) expand a collapsed selection. Here's a quick before/after shot of code collapse in practice- make sure to check out Greg Rewis' blog post here for a Captivate simulation of Code Collapse in action as well (Greg and I will be tag-teaming some of these daily posts for a richer description of the new features in Studio 8, so heads-up!).

So what if you'd like to maintain your selection, but hide/collapse everything else? Control-Alt-C/Control-Alt-E (Win) and Command-Option-C/Command-Option-E (Mac) will correspondingly collapse and expand everything outside your selection. And if you don't have time to make a full selection, but want to collapse the tag your cursor's currently within- either select 'Collapse Full Tag...' from the 'Edit > Code Collapse' menu, or just hit Control-Shift-J (Win) or Command-Shift-J (Mac). You can also achieve the inverse - collapsing all the code outside the tag/function your cursor's currently within - by hitting Control-Alt-J (Win) or Command-Option-J (Mac).
Flexible and powerful, once you've embraced code collapse there's no reason to get buried in your own code anymore- unless you want to, of course.

Is code collapsing persistent? In other words, can I close & re-open a document and all collapsed regions remain?
I saw that this morning, blogged it as well. My burning questions are now:
1) Can this be automated in the sidebar (eg: collapse on a tag, by clicking in the gutter, a la Visual Studio or SEPY)?
2) Is this only available for (html-ish) tags, or can this be used in(side) script blocks as well?
Will this work on .as files? If so, will we see it in Flash 8's AS editor? That would be sweet.
N Rohler- yep, code collapsing is persistent, even between application restarts. State is remembered between sessions.
Jason- re: #1- yes- there is a coder's toolbar in DW8 (I'll feature that in the near future) that includes commands for the key code collapse features (collapse full tag, collapse selection, expand all). Re: #2, yes- it works on all files, although the 'collapse full tag' feature (i.e. auto-sensing the larger block to collapse) only works with tags, you can still collapse selections as needed in other filetypes.
PaulC- yep- all files are supported, although as noted above, tag-based languages get the benefit of the 'collapse full tag' feature which autosenses the correct opening/closing of the block you're within. I've been using this with all file types (AS, PHP, CF, etc.) for the last month, and it's pretty addictive. ;-)
Hope this helps clarify things a bit more!
This is a feature Homesite has had for years... (5, a decade?) It's about time for DW to finally get it. Same, too, with the the "new" CSS panel -- TopStyle has had this for 5 years. Maybe MM got Nick to put in about 10 minutes of his time to add some real value to DW capabilities.
No one's twisting your arm to switch, font9a- nice sour grapes, though... lol
Where is the code collapsing data stored? As comments in the HTML, or the _notes, or some other method?
Thanks,
N Rohler
I *believe* the collapse state data is stored in the respective _notes repositories- I'm going on memory right now, though.
(If that's not the case, I'll post back with more detailed specifics.)
When I collapse a code, I see only the 7 first characters of first line and three dots,
-example----------------
41 + functio...
48 + functio...
72 + functio...
------------------------
it would be great if i can fonfigure to se more characters of a full first line,
is any way to do that?
thx, in advance
Sorry, Enver- I'm not aware of a way to configure that part of the feature. That's a great idea, though- make sure to submit a feature request for it directly to the product team:
http://www.macromedia.com/go/wish/
Collapse settings can be modified editing the registry.
You can see all setting in
(HKEY_CURRENT_USER|HKEY_LOCALMACHINE)\Software\Macromedia\Dreamweaver 8\Code Collapse
MaxChars,MaxChars per Tooltip line and MaxToolTip lines can be set.
As for the collapse information, it is stored files located in
Documents and Settings\(USER)\Application Data\Macromedia\Dreamweaver 8\Configuration\CodeCollapse\cache\