VSCode - 如何运行自定义代码段

时间:2018-01-29 20:34:36

标签: visual-studio-code code-snippets

为VSCode创建自定义代码段后,如何执行/运行它?

我创建了这个JavaScript测试代码段:

{
    "sns": {
        "prefix": "sns",
        "body": [
            "var http = require(\"http\");",
            "",
            "http.createServer(function(request, response) {",
            "  response.writeHead(200, {\"Content-Type\": \"text/plain\"});",
            "  response.write(\"This is a response...\");",
            "  response.end();",
            "}).listen(8888);"
        ],
        "description": "Simple node server code"
    }
}

我该如何触发它?

1 个答案:

答案 0 :(得分:-1)

我通常使用Code Runner扩展程序来运行代码段,我希望这会有所帮助。 https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner