views:

860

answers:

5

I know this is a long shot - but is there any way at all to get code folding into Delphi 7?

I'm working on some .. "suboptimal" .. code. Sometimes I really need to fold bits away to grok a stupid-long procedure. Currently I'm pasting code into Notepad++, which works, but it would be nice to have it in the IDE.

+2  A: 

Look for "method folding" on this FAQ (for GExperts) and you'll see that even this team, which has added many enhancements to Delphi, doesn't think this is in the cards for Delphi 7. I've looked for solutions and haven't seen them.

Argalatyr
+2  A: 

Not exactly the same, but you could put your "folded" code into a separate file, then include the file using the {$I filename.inc} compiler directive. Its been awhile since I used Delphi 7 but I believe if you put the cursor on the filename and hold control and click the filename will open in the ide.

skamradt
Ctrl+single-click actually, but that's not a bad idea at all. Easy way to break up some giant units without having to actually restructure the code.
Blorgbeard
+1  A: 

{$i filename.inc} is the right way. I had similar suboptimal code and had 8.000 lines of "dead" database-udating code placed outside the main form (bringing it down to 12.000 lines of suboptimal code). An include file helps isolating functionality and therefore eases the final task of making it into a class.

+1  A: 

I don't know any way to do the code folding in Delphi 7, but there are some Delphi plug-ins that will make viewing code much better

Castalia for Delphi http://www.twodesks.com/castalia/

and the free one cnPack http://www.cnpack.org/index.php?lang=en

Mohammed Nasman
cdPack is pretty cool! The code outlining is really nice.
Blorgbeard
A: 

As already mentioned, you could use the include file. But personally I don't like the idea of removing parts of code to another file, especially parts of a procedure (if I interpret your question the right way). I would prefer using bookmarks to rapidly navigate through the procedure, skipping the irrelevant parts, and the Ctrl+Shift+Up/Down key combinations to alternate between implementation and definition of methods.

The_Fox
I do use bookmarks too. I've not broken up procedures, but I did end up extracting two 1000+ line procedures to their own .inc files.
Blorgbeard