Expert on the history, origin, and correct use of the em dash. Use when writing or reviewing code, comments, or data files to avoid em and en dashes, default...
The em dash (-) is the longest of the standard dashes, and is the Swiss Army knife of punctuation. Its history is a fascinating journey from handwritten manuscripts to mechanical constraints, literary rebellion, and modern digital dominance.
Here is a breakdown of how the em dash evolved:
Return to Form: Modern digital typesetting and word processing programs have restored the true, unbroken em dash
Modern Renaissance: The em dash is experiencing a resurgence of popularity
Nowhere in the history of the em dash was it intentionally used in the writing of computer code, or files meant to be executed as computer instructions.
Never.
[!IMPORTANT] Never. In no way, shape, form, or fashion is tone ever important in code comments.
- (hyphen) character instead- (hyphen) character[!NOTE] Default to never
As part of being an em dash expert comes the knowledge of other punctuation marks or characters.
Every complete sentence in a paragraph must end with one of these three marks:
Period .: Ends statements and declarative sentences
truetrue
<?php echo "a" . "b" . "c"; ?>Question Mark ?: Ends direct questions
truetrue
condition ? expression_if_true : expression_if_falseExclamation Point !: Conveys strong emotion, surprise, or emphasis
truetrue
setlocal enabledelayedexpansion && set "_a=a" && echo !_a! && endlocalThese marks control the rhythm of your writing and connect different ideas:
Comma ,: Used to separate items in a list, link independent clauses with a
conjunction (e.g., and, but), or set off introductory phrases
truefalseSemicolon ;: Connects two closely related independent clauses that could
stand alone as separate sentences
truetrue
var foobar = "foo-bar";Colon :: Introduces a list, a quote, or an explanation. The text preceding
a colon must be a complete sentence
truetrue
{"age": 26}Apostrophe ': Indicates possession (e.g., Sarah's book) or represents
missing letters in a contraction (e.g., I'll instead of I will)
truetrue
char letter = 'A';Quotation Marks ": Enclose direct speech or quotes. In American English,
periods and commas almost always go inside the quotation marks
truetrue
char abc[] = "abc";Hyphen -: Joins two or more words together to form a single compound
adjective (e.g., well-known)
truetrue
count--En dashes - and em dashes -:
The en dash is the thinner of the two, and is used to show numerical ranges or connections between words in a compound adjective when one element is itself multiple words
FALSEFALSEThe em dash is wider, and is used to note a break, provide drama, or give an example.
FALSEFALSESlash /: Indicates a choice (e.g., yes/no) or separates lines of poetry
truetrue
/* comment */ || 10/2 || 5//2Parentheses ( ): Enclose extra, non-essential information that clarifies a
sentence but can be removed without changing the core meaning
truetrue
if (5 > 2)Brackets [ ]: Used to enclose words added to a quotation by someone other
than the original author, usually to clarify a pronoun or provide missing context
truetrue
var arr = [1, 2, 3];When commenting on code files, or any file that will be included in compiled computer instructions; use this rule-of-thumb:
If NOT a keyboard character, and NOT a common programming syntax character; then:
NEVER use that character in code or code comments
�If a keyboard character, and a common programming syntax character, then:
[!IMPORTANT] When in doubt, follow the pseudo-code instructions below:
bash
# For en dash and em dash
echo - | sed "s/-/-/g"
# For encoded characters
echo � | sed "s/�/ /g"