wwwwwllllk 发表于 2022-10-25 18:34:30

vscode去除log输出的分号,添加代码片段

本帖最后由 wwwwwllllk 于 2022-10-25 19:01 编辑

每次打log的时候它会带出分号,我很烦。我想去掉它。
!(data/attachment/forum/202210/25/182709wdznst3nrddnt8xd.png)


其实这就是vscode默认设置的代码片段

步骤:
1.!(data/attachment/forum/202210/25/182910bskz6oocl8ekc084.png)

2.!(data/attachment/forum/202210/25/183138jqi33q9ddmd77w25.png)

3.如果要新加一个片段(重新加载一个vscode)

!(data/attachment/forum/202210/25/183235tpce1o1hm6svczck.png)

好了
!(data/attachment/forum/202210/25/183407bwfbcbf1cvyiiw5v.png)!(data/attachment/forum/202210/25/183407ee66eytcz7cz0wtw.png)


```
{
        // Place your snippets for javascript 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"
        },
"create Annotation": {
                "prefix": "/**",
                "body": [
                        "/**",
                        "* @Description",
                        "* @author xx",
                        "* @date ${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE} ${CURRENT_HOUR}:${CURRENT_MINUTE}:${CURRENT_SECOND}",
                  "*/"
                ],
                "description": "创建注释"
        }
}
```

当然如果有人写的时候不会纠结格式,最后prettier格式化就好了。(取消勾选就是不加分号)
!(data/attachment/forum/202210/25/183551zddovsnkbdg6gdbi.png)

王一之 发表于 2022-10-25 21:59:40

我倒一般都带;

李恒道 发表于 2022-10-26 11:15:04

也可以设置prettier规则自动保存吧
感觉那样比较通用方便~
页: [1]
查看完整版本: vscode去除log输出的分号,添加代码片段