Search code examples
visual-studio-codelatexcode-snippetsvscode-snippets

VSCode Snippets for Latex: Combining placeholders and curly braces


I'm in the process of setting up a file for personal snippets in VSCode for LaTeX. Is there a way to combine placeholders (Syntax: ${1:foo}) and normal curly braces? In my example I want my code to output: \fcolorbox {frame}{background}{text} where every variable is a placeholder. My generated snippet code (.json) looks as follows:

    "Colorbox fcolorbox": {
  "prefix": "colbox",
  "body": [
    "\\fcolorbox ${{1:frame}}${{2:background}}${{3:text}}"
  ],
  "description": "Colorbox fcolorbox"
}

but doesn't work since it outputs and interprets the $ and {} as LaTeX symbols. Is there a way to fix this and make the placeholders work?


Solution

  • This produces the requested result: \fcolorbox {frame}{background}{text}

    "Colorbox fcolorbox": {
        "prefix": "colbox",
        "body": [
          "\\fcolorbox {${1:frame}}{${2:background}}{${3:text}}"
        ],
        "description": "Colorbox fcolorbox"
      }