简体   繁体   中英

How to escape $ on Sublime Text Snippet

I create a snippet for my PHP laravel in SBT3

<snippet>
    <content><![CDATA[
dd("${1}",${1});
]]></content>
    <tabTrigger>dd</tabTrigger>
    <scope>source.php</scope>
</snippet>

When I typed dd

I see this now.

在此处输入图像描述

if I type more

在此处输入图像描述

notice it's wrong?

It need have the $ like this

dd("nameofTheVariable",$nameofTheVariable);

How do I modify my snippet to escape the $ ?

The nameofTheVariable is stored in ${1} , so you'll need to add another $ before it.

Use a backslash ( \ ) to escape it: dd("${1}",\$${1});

<snippet>
    <content><![CDATA[
dd("${1}", \$${1});
]]></content>
    <tabTrigger>dd</tabTrigger>
    <scope>source.php</scope>
</snippet>

输出

Note : I've placed a space ( ) after the comma ( , ) as PSR-2 prefers it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM