起因
前两天了解到 markdown
编辑器,于是学习了下 markdown
的相关语法。自己平时学前端,用 sublime
比较多,也懒得下载其它的编辑器了,就用 sublime
写。有些标签也懒得写,就想用 sublime
的 snippet
来添加 markdown
的相关标签顺便也熟悉下 snippet
的写法,方便以后用。
动态图演示
Snippet
mdh1 // Heading 1
mdh2 // Heading 2
mdh3 // Heading 3
mdh4 // Heading 4
mdh5 // Heading 5
mdh6 // Heading 6
mdb // Bold
mdi // Italic
mdbq // Blockquote
mdhr // Horizontal Rule
mdic // Inline Code
mdbc // Block Code
mda // Anchor
mdimg // Image
mdol // Ordered List
mdul // Unordered List
所有的 md
表示的都是 markdown
,剩下的是英文缩写。
源码
接下来放出所有源码,供大家探讨:
{
"scope": "text.html.markdown",
"completions":
[
{ "trigger": "mdh1", "contents": "# ${1:Heading1} #\n\n${2:Next Line}"},
{ "trigger": "mdh2", "contents": "## ${1:Heading2} ##\n\n${2:Next Line}"},
{ "trigger": "mdh3", "contents": "### ${1:Heading3} ###\n\n${2:Next Line}"},
{ "trigger": "mdh4", "contents": "#### ${1:Heading4} ####\n\n${2:Next Line}"},
{ "trigger": "mdh5", "contents": "##### ${1:Heading5} #####\n\n${2:Next Line}"},
{ "trigger": "mdh6", "contents": "###### ${1:Heading6} ######\n\n${2:Next Line}"},
{ "trigger": "mdb", "contents": "**${1:Bold Text}**${2:}"},
{ "trigger": "mdi", "contents": "*${1:Italic Text}*${2:}"},
{ "trigger": "mdbq", "contents": "> ${1:Blockquote Text}\n\n${2:Next Line}"},
{ "trigger": "mdhr", "contents": "***\n${1:Next Line}"},
{ "trigger": "mdic", "contents": "` ${1:Code} `"},
{ "trigger": "mdbc", "contents": "```\n${1:Code}\n```\n\n${2:Next Line}"},
{ "trigger": "mda", "contents": "[${1:Website}](${2:URL})"},
{ "trigger": "mdimg", "contents": "![${1:Alternate Text}](${2:URL})\n\n${3:Next Line}"},
{ "trigger": "mdol", "contents": "1. ${1:Ordered List 1}\n1. ${2:Ordered List 2}\n1. ${3:Ordered List 3}\n\n${4:Next Line}"},
{ "trigger": "mdul", "contents": "- ${1:Unordered List 1}\n- ${2:Unordered List 2}\n- ${3:Unordered List 3}\n\n${4:Next Line}"},
]
}
如何配置 sublime-snippet
,请参考我的另一篇文章 Sublime Text 3-snippet菜鸟教程(动态图演示)