There seems to be a bug with esc key, strings, and underscores.

For instance, see the following code:

a = f["1_2"];

If an esc character is typed anywhere between the start of the line and the letter f, the first quotation mark is no longer recognized.

It appears that this occurs only when:

  • the string contains at least one underscore and at least one number (can have other characters too)
  • the string needs to have some sort of brackets (parentheses, curly braces, etc.) around it.

Trying to evaluate the line when the phenomenon occurs leads to an error.

Typing anything other than esc before the second quotation mark fixes the line.

What is causing this?

  • 2
    $\begingroup$ I've seen similar kinds of problems. See, for instance, here. There, it's a problem with superscripts. $\endgroup$
    – march
    Jul 25 '16 at 22:20
  • 1
    $\begingroup$ Also, here and here. $\endgroup$
    – march
    Jul 25 '16 at 22:37
  • $\begingroup$ Also, double esc before a, then double backspace and highlighting is broken. $\endgroup$
    – Kuba
    Feb 6 '17 at 8:19
  • $\begingroup$ Probably related: undo after copying a string inside a string $\endgroup$
    – Kuba
    Feb 6 '17 at 8:37