简体   繁体   English

如何在其中包含“ $”的Visual Studio Code中编写代码片段?

[英]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.

相关问题 如何在Visual Studio代码段中使用$? - How to use $ in Visual Studio Code snippets? 我在哪里可以找到带有 PHP 用户片段的扩展程序或网站,以在 HTML 文件中使用? (Visual Studio 代码) - Where can I find an extension or website with PHP user snippets to be used in an HTML file? (Visual Studio Code) Visual Studio 代码用户片段不适用于 php - Visual studio code user snippets not working for php 我如何通过下面的代码片段获得不同的价值 - How can i get the different value with code snippets below 为什么我不能写“ - Why can't I write "<?PHP" tag when I'm starting PHP in Visual Studio Code? 如何在 Visual Studio Code 中启用 PHP 语法突出显示? - How can I enable PHP Syntax highlighting in Visual Studio Code? 如何在 Visual Studio Code 中使用 HTML 标记格式化 PHP 文件? - How can I format PHP files with HTML markup in Visual Studio Code? 如何在不使用 XAMPP 或 WAMP 服务器的情况下在 Visual Studio Code 上调试 PHP Laravel - How can I debug PHP Laravel on Visual Studio Code without use XAMPP or WAMP server 我如何在main.js文件的jQuery函数内编写php代码 - How I can write a php code inside a jQuery function in main.js file 我怎样才能在 html 表单动作中正确编写这个 php 代码? - How can i write this php code inside html form action correctly?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM