1

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.

enter image description here

if I type more

enter image description here

notice it's wrong ?

It need have the $ like this

dd("nameofTheVariable",$nameofTheVariable);

How do I modify my snippet to escape the $?

code-8
  • 54,650
  • 106
  • 352
  • 604
  • I don't have Sublime Text installed at the moment so I can't verify it, but try adding the dollar sign escaped: `dd("${1}",\$${1});` – Petr Hejda Mar 25 '21 at 21:10

1 Answers1

2

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>

Output

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

0stone0
  • 34,288
  • 4
  • 39
  • 64