As you probably know, I've been reviewing a lot of HTML editors for the last month. And one feature that many HTML and code editors offer is "code folding". This is where you can highlight a block of HTML code and "fold" it, effectively hiding it from view. It's not gone from the document, it's just hidden from view while you edit the entire document. But I think I've used it twice in my life, and most of the editors I use regularly (
Dreamweaver,
Komodo Edit, and others) do have it. Do you use code folding or is it one of those features that you ignore?
It’s a great way to get a quick overview of a document and it’s also very useful for debugging not only code (e.g. PHP) but also sorting out errant DIVs and the like.
We develop our sites with Microsoft Visual Studio 2008, and this “code folding” feature is actually referred to as “outlining.” But yeah, it’s super useful for keeping the code very clean and modular.
We use Eclipse with the web and PHP perspectives; both of which use “code folding.”
@Dave: okay, both your programs have it, but do you use the feature? Nearly every editor I use has code folding, but I don’t use the feature.
You used it twice only! That’s not bad. I use it often as the code gets longer it helps me a lot to see where did I start in short span without scrolling back and forth.
Sanjay
Designer and Coder
UnicHost Web Hosting Solutions
If your web page contains lot of menus and large headers and footers, code folding may be useful. I personally don’t use it, if I have to edit something quick, then ”search” function is the solution.
@Jennifer Kyrnin: yes, I use the feature when dealing with nested blocks of code to be sure I’m working within the correct hierarchical level. (Think PHP do/for loops, etc).
Technically, “good” source files (PHP, HTML, JSP) shouldn’t be so incredibly long in the first place, but code folding is still useful when you want to put a specific area of the source file “under the microscope.”
Our vision is pool, the display is limited too. But we can’t “delete” the code indifferent provisory,it’s the tweak to use “code folding”.
Personally, aside from folding header comments, I never use it, and I discourage teams I work with from using it. With the scripting and templating tools we use, it’s my strong opinion that if you’ve got so much code that you’re tempted to use folding to get a higher-level view of your current file, then that’s a code smell – you need to refactor and split things up to where each individual piece is understandable as a unit, with a page/screen or two of meaningful content. There are (extremely rare) exceptions to this, but if you look closely at them, you’ll often find they have other serious issues – and addressing those will yield cleaner code.
I inherit a lot of awful HTML when I am redesigning sites and I use the feature in Dreamweaver to figure out the tables. I’ll work from the inside out, folding each td, then, tr, etc. It is a lifesaver when I get tables that are nested 6 and 7 tables deep!
It’s very useful on occasions when building sites with lots of DIV’s and held together with CSS. For example on site I’m working on, the base page that spews out the dynamic elements has 14 levels deep of Divs. Think of a wrapper, a header, a middle area with 3 columns, inside those are 4 containers holding other containers, an end of page area, a footer and so on and on. Each of THOSE areas also may call or include snippers of code or html that pull in yet more Divs.
If one breaks or you have one too many by accident as is common when you’re shuffling elements around as you build,… well the whole page breaks.
Folding from the middle of the page (not visually but code wise) outwards by folding in known div containers is extremely helpful and can save hours and hours or troubleshooting.