html执行代码块,vscode——如何自定代码块和调用代码块

本文详细介绍了如何在VSCode中创建HTML代码片段,通过设置快捷键,实现光标闪烁并插入预设的`PageTitle`,提升开发效率。步骤包括创建用户代码片段、配置`HTMLtemplate`,并演示了如何在其他HTML文件中使用这个自定义模板。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

3.在vscode左下方(像齿轮一样图标)——>选择"用户代码片段"——>如图:

a688ae142d47f3d2c9bc61696f17ff13.png

4.如图:

38af601ff391ff3333798d30647bb851.png

—>选择html点击——>html.json格式——>如图:

295242f0c24472ff348cdd7cdf7128f1.png

5.把这段代码:

"HTML template":{

"prefix": "cc",

"body":[

"",

"",

"",

"\t",

"\t${1:Page Title}",

"",

"",

"\t$0",

"",

""

},

"description":"Simple HTML5 starting point"

}

6.放入到代码中——>把设定好的代码块——>改名;

{

// Place your snippets for html 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"

// }

"HTML template":{

"prefix": "hy",

"body":[

"",

"",

"",

"\t",

"\t${1:Page Title}",

"",

"",

"\t$0",

"",

""

},

"description":"Simple HTML5 starting point"

}

}

***\t——>前面有四个空格

***${1:Page Title}——>代表下一次点光标——>大括号里的内容就闪烁;

7.在其它任何一个.html文件中——>输入“修改好的文件名”+tab——>就会出现以下代码段为"开头代码";

Page Title

description

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值