Skip to content

Better handling of \\) in nested environments #2311

@xsrvmy

Description

@xsrvmy

The current behaviour of \\) is to group the \ with \). Although this is not technically correct, it is actually the desirable behaviour since it prevents the rest of the document from being rehighlighted/reconcealed when entering commands in math mode.
However consider the following:

\(\begin{bmatrix}
a\\b\\)
\end{bmatrix}\)

Here \\) is intended to insert a new line. However this instead breaks syntax highlighting.

I am proposing the following behaviour:

  • If \\) appears in the top-level of an inline math expression, highlight it as \ and \), as using \\ in inline math is very rare, and the user's cursor is likely between the two \'s.
  • If \\) appears in an environment nested inside inline math, highlight it as \\ and ).
    (Note: I don't know how vim's highlighter does tokenizing/parsing, so if this is not possible please close the issue.)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions