失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > vscode怎么创建自定义代码片段

vscode怎么创建自定义代码片段

时间:2022-03-26 09:45:12

相关推荐

vscode怎么创建自定义代码片段

开发工具|VSCode

vscode,自定义

开发工具-VSCode

精美框架源码,ubuntu怎么设置邮箱,tomcat设置初始化内存,爬虫的具体作用,php7代码编译,seo计费标准lzw

这里以创建一个 javascript 代码片段为例:

易语言数据库源码,vscode如何更改浏览器,手机ubuntu测评,tomcat四层配置,内鬼和爬虫,php pecl 下载,惠州seo关键词优化服务,个人网站界面模板lzw

1、首先可以打开一个javascript的文件(或在当前打开文件中)按快捷键Ctrl+Shift+P打开命令输入 snippet : (也可以点击文件=>首选项=>用户代码片段)

公司考勤系统源码,阿里云ubuntu 桌面,tomcat6线程数设置,小爬虫橘猫,我要的php代理源码,seo556688lzw

2、选择选项后会出现一个语言列表用以选择给哪种语言创建代码段。这里以设置javascript的Console.WriteLine代码段为例,其他语言方法是一样的。

选择javascript后会自动打开一个JSON格式的配置文件

{// 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"// },}

根据自身需要修改内容如下:

{// 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:"Page Header": {"prefix": "ducx","body": ["/**"," * $1"," * "," * @author ducx"," * @created $CURRENT_YEAR/$CURRENT_MONTH/$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND"," */","$2"],"description": "page header"}}

保存之后,打开一个 js 文件,输入前缀 ducx 出现快捷提示窗后回车,此时已经生成了我们自定义的代码片段结构,依次按 tab 。

/** * * * @author ducx * @created /08/31 17:08:37 */

推荐教学:vscode教学

如果觉得《vscode怎么创建自定义代码片段》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。