2

How can I insert a literal $1 in a snippet, using snipMate? I could not find that information in the manual…


Results in nothing (tries to find a placeholder):

snippet s
    $1

Result in $ only:

snippet s
    $$1
sidyll
  • 57,726
  • 14
  • 108
  • 151

3 Answers3

5

I found a workaround. Use $${0:1}. SnipMate doesn't interpret ${0}, but seems to insert the default text instead.

Adam H. Peterson
  • 4,511
  • 20
  • 28
1

Basically, you can't. The closest workaround is using default text:

snippet s
    $${1:1}

This requires you to hit tab once.

This is a listed issue with snipMate -- and has been for two years, so I wouldn't hold my breath waiting for it to get fixed.

Lstor
  • 2,265
  • 17
  • 25
  • I hope you will forgive me, but I decided to change the correct mark to @Adam H. Peterson who found a solution months after this question was posted. I though you'd be interested in knowing it also; for me it's specially essential in makefiles. – sidyll Jun 14 '11 at 18:37
1

I am currently on a promoting tour for UltiSnips on StackOverflow. UltiSnips support escaping chars, the corresponding snippet looks like this:

snippet s
\$1
endsnippet

A conversion script for snipMate snippets is shipped with UltiSnips, so switching is easy.

SirVer
  • 1,397
  • 1
  • 16
  • 15