Headings and lists
Over the last couple of lessons we have looked at the most basic elements of a plain text file: characters, words, sentences, lines and paragraphs. Now we start ramping things up a bit.
If you ever want to write something longer than a couple of lines -- and most plain text files in everyday usage are often quite longer than this -- you will eventually start to think about the structure of your document.
Headings
Much like this document, you would want headings and subheadings and possibly dividers and more to lay your document out in such a way that it is easily scannable. We can all agree that a wall of text is not scannable.
While there are a couple of different ways to do this, we will begin with the simplest now and discuss more robust ways when we talk about markdown.
A heading, when you think about it, is simply a really short paragraph. So a heading in a plain text file is simply the heading with an empty line above and below it (unless that is how you start your document, in which case it just has an empty line below it).
This is a heading
And this is the body to which that heading belongs.
How do we know, though? Visual cues, mostly.
When you look at that line you can tell it is a heading
probably because of its wording, probably because of
how it is placed there all by itself, or probably
because of how this paragraph beneath is so different.
Either way you look at it, the beauty of plain text
lies in its simplicity and our human nature to be
able to quickly, effortlessly recognise unwritten cues.
Nobody will look at this extract and not identify
the first line as a heading.
Is it really as simple as that? For most plain text documents you write, yes. Because most documents we write rarely become anything else. If you want a to-do list, or you want to make a note of emails of people you met at a conference, you can just write the title ‘Attendees at XYZ conference’ on a line and start typing in one email address per line. It rarely needs to be more complicated than this.
But if you do want to have a more complex structure, say with multiple heading levels, and you plan to output your plain text file as a good-looking PDF handout, you would want headings to look different from the body text -- you want different formatting. For this we use markup, and we will discuss this in a later lesson.
Lists
Another common element in a plain text file is a list. A list can be as simple as words on separate lines. Think of our list of emails from a conference in the previous section. It might look like this:
Attendees at XYZ conference
9--11 July 2024
Chemin du Petit Saconnex
Geneva, Switzerland
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
That is more than just good enough. You have everything you need, nothing you do not.
You might wonder, though, if line breaks do not matter for plain text, would these emails not together collapse to form a single long line? Indeed, they would. If you only ever use this plain text file as plain text, you have nothing to worry about. But if you want to turn this into a properly styled list some day, you might want to somehow mark list items to indicate that they are, in fact, a list and not a sentence.
Symbols we use to indicate such things -- structure in this case, where we want to demarcate a list, but possibly also formatting -- are called markup. Markup are characters that are not part of the content but are instead used along with the content to impart formatting, structure or other properties to the content.
For lists, our markup is as simple and intuitive as a hyphen. Here is what our list might look like with markup:
Attendees at XYZ conference
9--11 July 2024
Chemin du Petit Saconnex
Geneva, Switzerland
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
Markup is generally not strict, with most markup symbols having variations that do the same job. This means using a hyphen is not a rule. You could use an asterisk * if you so prefer, or even a plus + or, the best part, you can use them all at once if you want to, say, indicate something to yourself based on bullet styles. And you can leave a line in-between perhaps to separate guests drinking alcohol before dinner from those preferring non-alcoholic drinks:
Attendees at XYZ conference
9--11 July 2024
Chemin du Petit Saconnex
Geneva, Switzerland
- [email protected]
+ [email protected]
- [email protected]
* [email protected]
* [email protected]
+ [email protected]
This will still display ‘normally’. The plain text bullets will be for your eyes only.
Attendees at XYZ conference
9--11 July 2024
Chemin du Petit Saconnex
Geneva, Switzerland
You can have two explicit lists too, labelling each group, using different bullets for visual distinction for yourself:
Attendees at XYZ conference
9--11 July 2024
Chemin du Petit Saconnex
Geneva, Switzerland
- Alcohol with dinner:
- [email protected]
- [email protected]
- [email protected]
* No alcohol with dinner:
* [email protected]
* [email protected]
* [email protected]
This will indent the sub-lists on the front-end too and keep everything else looking uniform and well put together:
Attendees at XYZ conference
9--11 July 2024
Chemin du Petit Saconnex
Geneva, Switzerland
- Alcohol with dinner:
- No alcohol with dinner:
Then again, you do not have to write them like this. You can make them two different lists with headings:
Attendees at XYZ conference
9--11 July 2024
Chemin du Petit Saconnex
Geneva, Switzerland
Alcohol with dinner
- [email protected]
- [email protected]
- [email protected]
No alcohol with dinner
- [email protected]
- [email protected]
- [email protected]
This conveys the same information with more spacing. It will then look like this when transformed into ‘normal’ text:
Attendees at XYZ conference
9--11 July 2024
Chemin du Petit Saconnex
Geneva, SwitzerlandAlcohol with dinner
No alcohol with dinner
All these examples with minor variations are intended simply to show you that you can achieve the same result in many ways with plain text. Just do whatever comes to you more intuitively rather than trying to learn and memorise any rules or syntaxes.
TIP Remember we have always said spaces are important. To mark a list item with a hyphen you should also remember to leave one space after the hyphen. So writing - Item marks a list item while writing -Item does not.
This document is part of the plain text lesson plan. If you are ready, you can proceed to the next lesson.