Sublime Forum

How can I enter double back quotes?

#1

I need to use the template string ,so I need enter back quotes like this:back quote ${str} back quote,

But in sublime text 3126,when I enter the back quote,only can enter single back quote…How can I enter double back quotes? I don’t want to enter twice…

0 Likes

#2

Are you talking about the backtick? It seems to be under special treatment. Only yesterday I tried this keymap:

[
    {
        "keys": ["`"],
        "command": "insert_snippet",
        "args": {"contents": "`$1`$0"},
        "context": [
            { "key": "selector", "operator": "equal", "operand": "text.html.markdown", "match_all": true },
        ]
    }
]

This works most of the times with a different key, but not the backtick. I wish this was different.

0 Likes

#3

That seems to work for me here, perhaps you have a conflict of some sort?

This example is slightly tweaked from yours to put the cursor inside of the inserted ticks (and wrap selection) but it works the way you have it there as well.

0 Likes

#4

Hey guy~Thanks for your answer,it can work in syntax:markdown absolutely,but I wanna it also can work in syntax:javascript .
Did you know some way to let it come true?

0 Likes

#5

I wanna to use it in javascript not markdown,is there any way to make it come true?

0 Likes

#6

If you change the text.html.markdown to text.js, it will trigger for JavaScript instead of Markdown.

0 Likes

#7

I changed it but sitll doesn’t work, can you show me your keymap setting about it?

0 Likes

#8

Oh sorry, that should be source.js, not text.js (brain fart).

The full example would be something like (put it inside of [ and ] as above if it’s your only:binding)

{
    "keys": ["`"],
    "command": "insert_snippet",
    "args": {"contents": "`${0:$SELECTION}`"},
    "context": [
        { "key": "selector", "operator": "equal", "operand": "source.js", "match_all": true },
    ]
}
1 Like

#9

As you see, still doesn’t work…it’s my only binding…

0 Likes

#10

OK…it worked I forgot add “[…]”…It’s done…

1 Like