vscode配置Configure User Snippets 不生效

正常Ctrl+shift+p打开"设置",Configure User Snippets -> python.json

{
    // Place your snippets for python here. Each snippet is defined under a snippet name and has a prefix, body and 
    // description. 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": {
    //     "prefix": "log",
    //     "body": [
    //         "console.log('$1');",
    //         "$2"
    //     ],
    //     "description": "Log output to console"
    // }
    // 自己定义的snippet
    "Print2": {
        "prefix": "print2",
        "body": [
            "print('$1')",
            "print('-' * 30)",
            "print($1)",
            "print('-' * 30)"
        ],
        "description": "Log output to console"
    },
    "Print@": {
        "prefix": "print@",
        "body": [
            "print('@' * 30)"
        ],
        "description": "Log output to console"
    }
}

 

配置完保存就行了,但是我的死活不生效,查了半天终于找到原因。

解决方法:

以json文件的形式打开"设置",设置->Open Settings(JSON),

"editor.suggest.showSnippets"改成true,否则怎么设置都不会生效

{
    "editor.suggest.showSnippets": true,
}

 

 
posted @ 2023-07-14 16:34  豆浆D  阅读(933)  评论(0编辑  收藏  举报