vscode配置Markdown snippet 的快捷键

Snippet 是?

不同文件的模板语法/代码片段,可以设置好后在不同类型文件快速插入,提高效率。
例如:可以在Markdown使用快捷键生成自己想要的模板内容,自定义输入时tab的跳转位置
在这里插入图片描述

具体设置

官方文档

生成snippet的在线网站 snippet-generator

ctrl+shift+p 打开面板进入snippet配置项在这里插入图片描述
选择要配置模板的文件类型,例如Markdown,会进入json配置文件;
在这里插入图片描述
markdown.json

{
	// Place your snippets for markdown 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"
	// }
	"record": {
		"prefix": "rr",
		"body": [
			"---",
			"",
			"- Time: $1 ",
			"- Previous: $2 ",
			"- Feel/notion: $3 ",
			"- Next to-do: $0 ",
			" ",
			"---"
		],
		"description": ""
	}
	
}
  • body 就是模板语法的生成内容,可以使用上面提到的模板网站使用。
  • prefix 是自动语法补全的提示词 ctrl+space 补全,(英文输入法下)。
  • 可以设置占位符,在编辑时使用tab键跳转,注意tab不能有其他插件的按键导致冲突(可以注释其他tab的快捷键),不然跳转不了。
  • 片段名可以设置,后续配合快捷键快速插入模板

配合快捷键可以快速生成模板,也可以在英文输入法下 ctrl+space 自动补全模板;
需要配置快捷键需要打开keybindings.json
在这里插入图片描述
添加如下,即可 ctrl+1 生成模板

    {
        "key": "ctrl+1",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus",
        "args": {
            "langId": "markdown",
            "name": "record"
        }
    }

name对应模板名称

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值