John Davidson

php - How to escape $ on Sublime Text Snippet

0 comments
Message:


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 $?



My Answer:
You can escape the $ character in Sublime Text snippets by using a backslash (\) before it. Here's how you can modify your snippet to escape the $ character:

xml

dd("${1}",\$${1});
]]>

dd
source.php



By adding a backslash before the $ character in the snippet, Sublime Text will treat it as a literal character and not as a variable placeholder. This way, when you use the snippet, it will output the $ character as part of the code.

Rate this post

4 of 5 based on 1718 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us