RealSebba
RealSebba

Reputation: 25

Snippet with prefix "``" (double backtick) not working for inline Markdown code block

For writing inline Markdown code blocks quickly, I want to use the following snippet:

"prefix": "``",
"body": ["`$1` $2"],

This snippet would enable me to just tab through the code block. The snippet however does not trigger when using ``.

If I try to escape the backticks with backslashes, the prefix ends up empty and doesn't work either.

"prefix": "\`\`",
"body": ["`$1` $2"],

enter image description here

Is it possible to use `` as a prefix?

Upvotes: 0

Views: 1060

Answers (1)

Mark
Mark

Reputation: 181794

I found an explanation for why backticks work as a prefix but the snippet suggestion must be manually triggered with Ctr/+space.

From snippets prefix support utf-8:

The prefix can be anything but "suggestions as you type" are only triggered when typing a word character. What that is defines the corresponding language. For non word prefixes suggestion must be triggered manually, using ctrl+space

Backticks are apparently not word characters in markdown, so you need to manually trigger the suggestions with Ctr/+space.

Otherwise this works:

"backticks": {
    "scope": "markdown",
    "prefix": "\\`\\`",      // note double backslashes
    "body": ["`$1` $2"],
}

demo of using backticks as a prefix in a snippet

Upvotes: 1

Related Questions