S
S
Sergey Burduzha2018-06-12 17:15:38
Sublime Text
Sergey Burduzha, 2018-06-12 17:15:38

How to properly escape the $ sign in sublime snippets?

I want to write such a snippet

<?php foreach(): ?>

 <?php endforeach; ?>

I write the following code in a snippet
<?php foreach(${\$1} as ${\$2:this}): ?>
    $(\$3:this};
<?php endforeach; ?>

When I turn, I get What did I not take into account? Thanks in advance
<?php foreach(${\ ?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Di Ma, 2018-06-12
@serii81

<?php foreach(\$${1:} as \$${2:this}): ?>
  \$${0:this}
<?php endforeach; ?>

A
alexpixel91, 2018-11-25
@alexpixel91

▼ Unofficial - official Sublime Text 3 documentation ▼
-- docs.sublimetext.info/en/latest/extensibility/snip... --
The easiest solution the documentation suggests is to use the backslash as an escape character before the dollar. Original text from documentation ▼
If you want to get a literal $, you have to escape it like this: \$.
For example:
There is a line in the snippet - Bz$f}qwTC$GmG}Us5dq?fIipsLcKD$D$vHI .
Enter backslashes - Bz\$f}qwTC\$GmG}Us5dq?fIipsLcKD\$D\$vHI.
Voila! Everything is working!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question