Sublime Forum

Escaping curly brackets in snippet

#1

In snippets, I can’t use tab to go to another placeholder $1 or ${1:sublime_is_awesome}
When string contains curly brackets like this:

<snippet>
	<content><![CDATA[
\{% $0 %\}
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>w</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<scope>text.html.twig</scope>
</snippet>

As u see I tried to escape but nothing happens :frowning:
After lunching snippet and pressing tab It goes to an end of the string and removes { } from whole string.
It doesn’t go to $0 at it supposed to do.

Please help

Cheers!

0 Likes

#2

Your snippet seems to be working just fine for me as expected.

0 Likes

#3

oh… big big sorry my brain got little overheated yesterday.
Can u try this one?

<snippet>
	<content><![CDATA[
\{% set user = fn(' ${1:function_name} ', '${0:arg1}') %\}
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>fn</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<scope>text.html.twig</scope>
</snippet>

for me: It won’t go to second location only to the end of the string and removes wrapping curly braces on start and end of the line.
If that will work for u, than I ll check all my packages and give some feedback.

0 Likes

#4

This snippet also works as expected based on the snippet content. It doesn’t remove the start { and end } of {% set ... %} for me (you can see in the GIF). It first goes to function_name since that’s the first placeholder and then arg1 and stops there since that’s the ending placeholder.

Edit: I don’t think you even need to escape { even {% set user = fn(' ${1:function_name} ', '${0:arg1}') %} as snippet content works.

0 Likes

#5

oh… thanks for ur time :). Than it has to be some confilct with one of the packages. will investigate on my own.

0 Likes

#6

IT was EMMET package which caused the issue. After disabling it all works great!
I changed emmet triggers to ctrl+e and all works great!

For those who encounters the same problem I solved it via adding ignoring certain scopes for emmet.
I added to emmet.sublime-settings (the users settings):

	"ignore_scopes": [
		"text.html.twig"
	]

Even tho u add ignoring emmet in certain scope, u can use emmets exapnsion by ctrl+e instead of tab

Thanks for checking @UltraInstinct05 I think it can be closed :wink:

0 Likes