« Studio 8 - It's Official | Main | FOTD 02 - Flash 8: Video Import Wizard »
August 08, 2005
FOTD 01: Dreamweaver 8 Code Collapse
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.
Posted by sfegette at August 8, 2005 10:02 AM
Comments
Is code collapsing persistent? In other words, can I close & re-open a document and all collapsed regions remain?
Posted by: N Rohler at August 8, 2005 10:30 AM
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?
Posted by: Jason Nussbaum at August 8, 2005 10:36 AM
Will this work on .as files? If so, will we see it in Flash 8's AS editor? That would be sweet.
Posted by: PaulC at August 8, 2005 11:21 AM
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!
Posted by: Scott Fegette at August 8, 2005 11:51 AM
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.
Posted by: font9a at August 8, 2005 07:44 PM
No one's twisting your arm to switch, font9a- nice sour grapes, though... lol
Posted by: Scott Fegette at August 9, 2005 08:18 AM
Where is the code collapsing data stored? As comments in the HTML, or the _notes, or some other method?
Thanks,
N Rohler
Posted by: N Rohler at August 9, 2005 08:21 AM
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.)
Posted by: Scott Fegette at August 9, 2005 08:30 AM
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
Posted by: Enver Kurteshi at September 29, 2005 08:45 AM
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/
Posted by: Scott Fegette at September 29, 2005 11:44 AM
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\
Posted by: Tony at January 31, 2006 05:40 AM