0

So I want to create a snippet for the following:

$("input").click(function(event){
    //code goes here
});

But when I try to create the snippet in sublime text:

<snippet>
    <content><![CDATA[
$("${1:Tag}").click(function(event)
{
    ${2:code goes here}
});
]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>sclick</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <scope>source.js</scope>
</snippet>

Obviously there is some sort of conflict between the '$' of both. I read through the docs but didn't find anything. How do I create a snippet for this?

1 Answer 1

2

Use \ to escape the $:

<snippet>
    <content><![CDATA[
\$("${1:Tag}").click(function(event)
{
    ${2:code goes here}
});
]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>sclick</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <scope>source.js</scope>
</snippet>

(It’s the only supported escape sequence.)

Sign up to request clarification or add additional context in comments.

1 Comment

Ohh yes totally forgot about these escape characters. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.