1

Sublime Text 2 snippet parsing error

Here is the error:

Error parsing content for snippet Packages/User/servlet-definition.sublime-snippet: Empty key

and here is the code:

<snippet>
    <content><![CDATA[
    <servlet>
        <servlet-name>$1</servlet-name>
        <servlet-class>${2:spray.servlet.Servlet30ConnectorServlet}</servlet-class>
        <async-supported>${3:true}</async-supported>
    </servlet>

    <servlet-mapping>
        <servlet-name>$1</servlet-name>
        <url-pattern>$(4:/*}</url-pattern>
    </servlet-mapping>

    ${5}
]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <tabTrigger>sdef</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <!-- <scope>XML</scope> -->
</snippet>

2 Answers 2

4

The problem isn't that Sublime Text 2 thinks you're using a regular expression, it's that $(4:/*} should be enclosed by just brackets, not a parenthesis and a bracket. As it is now, Sublime Text is wondering why your $ isn't part of a variable. Use ${4:/*} instead, and you should be fine.

Also, you can use $0 to define the exit position for the cursor—it looks like you're using $5 for that purpose, which will be a problem in the future if you want to add more fields.

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

Comments

0

$(4:/*} is the problem. Not sure why, seems like maybe it is being evaluated as a regex. I tried escaping the forward slash but no luck. I just removed the default text.

Comments

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.