How to use code folding in .txt files?

864 views
Skip to first unread message

CharType

unread,
Jun 23, 2018, 9:34:32 PM6/23/18
to BBEdit Talk
I have some plain .txt files that I have divided into sections, and I would like a way to collapse the sections I'm not using. I know about custom folding, but I would like to fold sections without manually defining each one every time I open the file. Something like the automatic code folding would work, but for plain text files. Being able to define my delimiters would be nice, but I can work with predefined delimiters. Does anyone know how to do this? Thanks.

Brian Forte

unread,
Jun 24, 2018, 9:46:07 AM6/24/18
to bbe...@googlegroups.com
BBEdit supports syntax-highlighting and code-folding for plain
text files marked up with [Markdown][1] syntax.

[1]: <https://daringfireball.net/projects/markdown/>

If you set a plain text file’s language to Markdown and
demarcate your sections with markdown-formatted headings like
this —

# section 1 #

Body copy goes here.

# section 2 #

More body copy goes here.

— you’ll see, in the BBEdit text window’s gutter, a
disclosure triangle beside each heading string.

Clicking said triangle will fold up the text below the string

# section 1 #

up until the string

# section 2 #

Hope this helps.

Regards,

Brian Forte.

--
words, edits, type, layout, code
<mailto:bfo...@adelaide.on.net>
<http://betweenborders.com/>

CharType

unread,
Jun 24, 2018, 7:53:10 PM6/24/18
to BBEdit Talk
Thanks. How do I set the file's language to Markdown?

Brian Forte

unread,
Jun 24, 2018, 9:38:18 PM6/24/18
to bbe...@googlegroups.com
On 24/06/2018 at 09:44, charty...@gmail.com (CharType) wrote:

>Thanks. How do I set the file's language to Markdown?

At the bottom of every BBEdit window is the Status Bar. By
default this
bar shows:

* the current insertion point position (as line number and character
number).

* the document’s assigned language. (If there is no assigned language
this displays as ‘(none)’.)

* the document’s text-encoding.

* the document’s line-break type.

* the document’s lock state.

* the document’s last saved date and time.

* the text magnification setting.

Clicking on the assigned language value produces a pop-up menu. Select
‘Markdown’ from this menu to set the document’s language
to ‘Markdown’.

Hope this helps,

Regards,

Brian Forté.

Tom Robinson

unread,
Jun 24, 2018, 11:00:01 PM6/24/18
to bbe...@googlegroups.com
In addition to Brian’s answer, you can also save the file with a .md extension (and possibly others)… which is the best approach if you are turning them into Markdown.

FYI the spec is http://commonmark.org/help/
Reply all
Reply to author
Forward
0 new messages