Sublime Forum

Folding Up in html

#1

I’m a new sublime user, transferring over from notepad++. One of the things I really liked about notepad++ was that it allowed you to fold up whole sections of html based on the tags alone. I notice that you can also fold up in Sublime, but it’s based on indentation (at least by default).

In case you don’t know what I mean, Imagine the following html:

<body>
<ul>
   <li></li>
</ul>
</body>

In notepad++, you would be able to fold up the ul and the body elements completely, regardless of the fact that the contents of body are not indented.
In sublime, by default, you would only be able to fold up the ul element because the contents are tabbed.

How can I add that notepad++ folding functionality to sublime?

[edit]
one very attractive solution is to just select everything and click ctrl+shft+p and find the ‘reindent lines’ command.

0 Likes

#2

AFAIK folding on sublime is not language specific and it’s based on indent.

0 Likes

#3

maybe there’s a plugin for it? I suppose it wouldn’t be too bad if it were only based on indents, as I suppose best practice is to indent anyway, but still…

0 Likes

#4

You can not access the indention arrows shown next to the line numbers using the API. The only way would be to fold a section using a plugin.
Maybe you can also do this with a macro since, iirc, there are a few commands which will expand the current selection to the end of the tag and then run the “fold” command. I do (unindented) HTML or XML only rarely if at all but maybe this is already enough information for you.

0 Likes

#5

wow, it’s a bug.
I’ve pasted a valid source of my page, and folding works verryyy unusual.

0 Likes

#6

[quote=“ArtDesire”]wow, it’s a bug.
I’ve pasted a valid source of my page, and folding works verryyy unusual.[/quote]

Found out why it’s happened to me. I had wrong count of indent. but it is not right that Sublime folding up by indent, not syntax. Also it folding up only some tags like html, body, div. tags like footer doesn’t folding up.

0 Likes