[英]Inserting $1 in a snippet with snipMate
How can I insert a literal $1
in a snippet, using snipMate?如何使用 snipMate 在片段中插入文字
$1
? 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
I found a workaround.我找到了解决方法。 Use
$${0:1}
.使用
$${0:1}
。 SnipMate doesn't interpret ${0}, but seems to insert the default text instead. SnipMate 不解释 ${0},但似乎插入了默认文本。
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.这是 snipMate 的一个列出的问题——并且已经存在两年了,所以我不会屏住呼吸等待它得到修复。
I am currently on a promoting tour for UltiSnips on StackOverflow.我目前正在 StackOverflow 上为UltiSnips进行宣传之旅。 UltiSnips support escaping chars, the corresponding snippet looks like this:
UltiSnips 支持 escaping 字符,对应的代码片段如下所示:
snippet s
\$1
endsnippet
A conversion script for snipMate snippets is shipped with UltiSnips, so switching is easy. snipMate 片段的转换脚本随 UltiSnips 一起提供,因此切换很容易。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.