VoiceGem

How to dictate a backslash for escapes and regex

Say “backslash” to produce a backslash bound on both sides, so “backslash n” assembles as the two literal characters \n rather than an actual line break. Saying “new line” instead inserts a real line break, which makes these two phrases the pair people most often confuse when they start dictating code.

A fourteen-word escaped pattern takes roughly 16 seconds to type and roughly 5.1 seconds to say. (sources: Dhakal, Feit, Kristensson & Oulasvirta, “Observations on Typing from 136 Million Keystrokes”, CHI 2018, 168,000 participants, 136 million keystrokes; Yuan, Liberman & Cieri, “Towards an Integrated Understanding of Speaking Rate in Conversation”, Interspeech 2006, 2,438 American English telephone conversations (Switchboard corpus). The speech figure is conversational rate, not a measured dictation rate — no such measurement exists.)

What lands in your editor
\d +\.\d { 2 }

This tool runs entirely in your browser. Nothing you type is sent anywhere, stored, or logged.

Step by step

  1. 1

    Say “backslash”, then the character it escapes

    Speak the two parts in order. The backslash binds on both sides, so “backslash n” lands as the two-character sequence with nothing between them.

  2. 2

    Keep it distinct from “new line”

    Say “backslash n” for the literal escape and “new line” for an actual line break. Both live in the same VoiceGem lookup pass but they are different entries producing genuinely different output.

  3. 3

    Chain them inside a pattern

    Say “backslash d”, “backslash w” or “backslash s” for regex character classes. Each is a backslash followed by a letter that passes through untouched.

  4. 4

    By hand

    Press the backslash key, unmodified on a US layout and directly above Return. Anyone writing a regex is already reaching for it constantly.

A backslash escape and a line break are different things in VoiceGem

Two entries in the lookup table produce something that sounds related and is not. Saying “backslash n” emits the backslash character followed by the letter n — two characters, exactly what a string literal needs. Saying “new line” emits an actual line break, which is a whitespace command rather than a symbol.

Both live in the same single pass over the transcript, so there is no mode to switch and no ambiguity to resolve. VoiceGem checks casing commands, then symbol phrases longest-first, then whitespace commands, then passes the word through — and “backslash” and “new line” land in different steps of that walk.

Where the manual way breaks

Typing a backslash is one unmodified keystroke, and inside a regex you are usually already in a dense run of them. The keyboard is fine here for anything short.

Escape-heavy patterns are the case worth speaking. A date pattern needs several escaped classes and literal dots, and every character in it is punctuation — the sort of line where a typo is invisible until the pattern silently fails to match. One honest caveat: the plus and brace quantifiers keep spaces around them in VoiceGem's table, so a dictated pattern needs whitespace stripped before it will compile.

Doing this somewhere else? the same speech-to-code converter this demo runs, what changes for the colon in a type annotation, the same thing for the comma in an argument list, or the double colon path separator.

Common questions

No. It produces the two literal characters a string escape needs. Say “new line” if you want an actual break in the text.

Say “backslash” then the letter, as in “backslash d”. The letter is not in the table so it passes through untouched, leaving the two-character class intact.

Quantifiers like the plus and the braces attach on neither side in VoiceGem's table, so they keep their surrounding spaces. Strip the whitespace after dictating, or run the line through your formatter.

Dictate an escaped pattern and see exactly which characters land.

Open the tool