Sublime Forum

How to fold everything between opening and closing HTML tag?

#1

Hello,
I’m Using ST3 build 3207.
There is a feature of sublime that, a down arrow sign appears on index of every opening tag that will allow me to fold everything between the open and closing tag, when I press the arrow sign.
for example, there are 2115 lines of html code. The opening html tag is at line 2 and closing html tag is at line 2114. Now, there is a :small_red_triangle_down: (down arrow) sign appears at line 2 [which is the opening htmL tag] that fold everything till the closing html tag, and the closing tag would placed right under the opening tag …
Like this…

But the problem is this down arrow sign doesnt appears in my every opening tag, not even at the html tag !!

Does anyone understand my problem , why is this causing ???
If anyone understand the problem and know the solution, it would be very kind if let me know…
Thanks…

0 Likes

How to fold everything between an opening and closing html tag?
#2

Code folding isn’t done based on the context of the language, it’s done based on the indent level of the code in question. Fold arrows only appear next to lines where there are at least two lines below that are indented.

In your example, the <html> tag is not followed by two indented lines, so there is no fold arrow. Similarly the <head> tag is only followed by a single indented line, so that does not get an arrow either. The comment on line 5 is followed by multiple indented lines, so it gets a fold arrow.

Regardless of where the fold arrows appear by default you can still select text and use the items in the Edit > Code Folding menu (or their keyboard shortcuts) to fold and unfold whatever you want. For the case of HTML it can also be handy to use the Selection > Expand selection to tag command to make the selection first.

For what it’s worth, more context and language specific code folding options has been requested previously; at the last report it wasn’t something that the devs said that they were working on at that time but it was also not something that was dismissed as something that would never happen.

0 Likes

#3

Ohh, Understood… thanks a lot :slightly_smiling_face:

0 Likes