4

Suppose, I have the following yasnippet:

my $dir = __FILE__;
$dir =~ s/(.*)\/.*/$1/;

$1 here is the regular expression first match. Not yasnippet special symbol. How can I quote it, so it is inserted into the code as is?

user4035
  • 22,508
  • 11
  • 59
  • 94

1 Answers1

5

From the documentation:

Arbitrary text can be included as the content of a template. They are usually interpreted as plain text, except $ and `. You need to use \ to escape them: \$ and \`. The \ itself may also needed to be escaped as \\ sometimes.

So use \$ to get a literal '$' in your snippet.

Tyler
  • 9,872
  • 2
  • 33
  • 57