Skip to main content

25.5 Quotation Marks

One common way to quote is the typewriter convention, which quotes using straight apostrophes 'like this' or double-quotes "like this". Another common way is the curved quote convention, which uses left and right single or double quotation marks ‘like this’ or “like this"1. In text files, typewriter quotes are simple and portable; curved quotes are less ambiguous and typically look nicer.

Electric Quote mode makes it easier to type curved quotes. As you type characters it optionally converts ` to , ' to , `` to , and '' to . It’s possible to change the default quotes listed above, by customizing the variable electric-quote-chars, a list of four characters, where the items correspond to the left single quote, the right single quote, the left double quote and the right double quote, respectively, whose default value is '(?‘ ?’ ?“ ?”).

You can customize the behavior of Electric Quote mode by customizing variables that control where it is active. It is active in text paragraphs if electric-quote-paragraph is non-nil, in programming-language comments if electric-quote-comment is non-nil, and in programming-language strings if electric-quote-string is non-nil. The default is nil for electric-quote-string and t for the other variables.

You can also set the option electric-quote-replace-double to a non-nil value. Then, typing " insert an appropriate curved double quote depending on context: at the beginning of the buffer or after a line break, whitespace, opening parenthesis, or quote character, and otherwise.

Electric Quote mode is disabled by default. To toggle it in a single buffer, use M-x electric-quote-local-mode. To toggle it globally, type M-x electric-quote-mode. To suppress it for a single use, type C-q ` or C-q ' instead of ` or '. To insert a curved quote even when Electric Quote is disabled or inactive, you can type C-x 8 [ for , C-x 8 ] for , C-x 8 { for “, and C-x 8 } for ". See Inserting Text. Note that the value of electric-quote-chars does not affect these keybindings, they are not keybindings of electric-quote-mode but bound in global-map.

  1. The curved single quote characters are U+2018 LEFT SINGLE QUOTATION MARK and U+2019 RIGHT SINGLE QUOTATION MARK; the curved double quotes are U+201C LEFT DOUBLE QUOTATION MARK and U+201D RIGHT DOUBLE QUOTATION MARK. On text terminals which cannot display these characters, the Info reader might show them as the typewriter ASCII quote characters.