Vscode Snippet
Last updated: Jun 16, 2020 |
Publish date: May 28, 2020
给多种语言添加相同的 snippet
VS code 可以给多个语言添加相同的 snippets.
以 latex 和 markdown 为例, 依次打开 File -> Preferences -> User Snippets,
然后选择 New Global Snippets File…, 输入文件名, 如 latex-md
回车即可创建
新的 snippet 文件.
然后添加如下 snippet:
"Environment": {
"scope": "latex,markdown",
"prefix": "begin",
"body": [
"\\begin{$1}\n\t$2\n\\end{$1}\n$0",
],
"description": "Insert New Environment"
}
注意上面的文件中用了 scope
变量, 用于指定语言.
snippet 编写规则
- Creating your own snippets
The snippet syntax follows the TextMate snippet syntax with the exceptions of ‘interpolated shell code’ and the use of \u; both are not supported.
- TextMate snippets