[英]How can I write Snippets in Visual Studio Code with an “$” inside of them?
I want to make a Code-Snippet in VSC but when I make a snippet and paste the code with "$" inside of it the "$" dissapears. 我想在VSC中制作一个代码段,但是当我制作一个代码段并在其中粘贴带有“ $”的代码时,“ $”消失了。 I know why but I dont know how I can fix this.
我知道为什么,但我不知道该如何解决。
This is for a PHP Site I'm coding on. 这是我正在编码的PHP网站。
//MYSQL - VERBINDUNG
"MySQL Verbindung": {
"prefix": "db_verbinden",
"body": [
"$dburl = 'localhost';",
"$username = 'root';",
"$passwort = '';",
"$dbselect = 'db';",
"",
"$db = mysqli_connect($dburl, $username, $passwort) or die('Die Verbindung mit der Datenbank ist fehlgeschlagen!');",
"mysqli_select_db('rbcms', $db);",
"",
]
},
So I want to make Snippets with "$" inside of them. 因此,我想在其中添加“ $”的代码片段。
As it is mentioned in the documentation you need to escape certain characters: 正如文档中提到的,您需要转义某些字符:
Below is the EBNF (extended Backus-Naur form) for snippets.
以下是摘要的EBNF(扩展的Backus-Naur形式)。 With
\\
(backslash), you can escape$
,}
and\\
.使用
\\
(反斜杠),可以转义$
,}
和\\
。 Within choice elements, the backslash also escapes comma and pipe characters.在选择元素中,反斜杠还会转义逗号和竖线字符。
https://code.visualstudio.com/docs/editor/userdefinedsnippets#_grammar https://code.visualstudio.com/docs/editor/userdefinedsnippets#_grammar
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.