yoowinsu / blog

issues blog
17 stars 3 forks source link

开发日记——配置VSCode中的代码片段 #77

Open yoowinsu opened 6 years ago

yoowinsu commented 6 years ago

配置VSCode中的代码片段

现在Visual Studio Code(以下简称vscode)在前端已经成为了编辑器的不二之选,vscode之所以受欢迎,也是因为有许多方便程序员开发的功能和插件,生态完善,其中用户代码片段功能是非常不错的功能,能非常便捷的帮助开发者提高工作效率,真香警告。

打开方式

这两种方式都可以新建一个全局代码片段文件,输入新建文件名称之后,文件打开默认是配置介绍和示例,如下:

{
    // Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and 
    // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope 
    // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is 
    // used to trigger the snippet and the body will be expanded and inserted. Possible variables are: 
    // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. 
    // Placeholders with the same ids are connected.
    // Example:
    // "Print to console": {
    //  "scope": "javascript,typescript",
    //  "prefix": "log",
    //  "body": [
    //      "console.log('$1');",
    //      "$2"
    //  ],
    //  "description": "Log output to console"
    // }
}

配置

完。