Vscode: Escaping \\ in snippet using \\\\ outputs only one backslash

Created on 7 Sep 2017  ·  1Comment  ·  Source: microsoft/vscode

  • VSCode Version: 1.15.1, Commit 41abd2
  • OS Version: Ubuntu 16.04

Steps to Reproduce:

  1. Insert the following code snippet to latex.json (which is where user's tex snippet goes)
    Or by clicking File -> Preferences->User Snippets and search tex.
    "Input a multiline eqn": {
        "prefix": "eqnmultiline",
        "body": [
            "\\[",
            "\t\\begin{array}{lcl}",
            "\t\t ${1:foo} & = & ${2:foo} \\\\",
            "\t\t & = & ${3:foo} \\\\",
            "\t\t & = & ${4:foo} \\\\",
            "\t\\end{array}",
            "\\]",
            "$0"
        ],
        "description": "Input a multiline eqn"
    }

  1. In a demo.tex, type eqnmultiline which will insert a code snippet as follows:
   \[
        \begin{array}{lcl}
             foo & = & foo \
             & = & foo \
             & = & foo \
        \end{array}
    \]

And I'm expecting a \\ at the end of the three foo lines, which I use \\\\ to escape. But the result is one \ at each line.
Snippet Grammer says using \ to escape \. So I'm wondering if this is a bug.


Reproduces without extensions:
Correct Sorry for not testing using suggested code --disable-extensions before because I missed that line in comment . Tried it today and after disabling extensions, I cannot insert tex snippets even through Command Palette. It tells me there are no entries to pick from

*duplicate *question editor snippets

Most helpful comment

Sorry for the mess... This dupe https://github.com/Microsoft/vscode/issues/32020#issuecomment-323775984 but in short this is the problem

  • In TextMate you can but must not escape a backslash with a backslash, so to insert 1 backslash have either \ or \\
  • In JSON you must escape a backslash with another backslash, so to insert 1 backslash have either \\ or \\\\, to insert 2 \\\\\\\\

There are idea to move away from JSON for this and other escaping challenges...

>All comments

Sorry for the mess... This dupe https://github.com/Microsoft/vscode/issues/32020#issuecomment-323775984 but in short this is the problem

  • In TextMate you can but must not escape a backslash with a backslash, so to insert 1 backslash have either \ or \\
  • In JSON you must escape a backslash with another backslash, so to insert 1 backslash have either \\ or \\\\, to insert 2 \\\\\\\\

There are idea to move away from JSON for this and other escaping challenges...

Was this page helpful?
0 / 5 - 0 ratings