如何在 VSCode 中添加自定义代码片段? [英] How to add custom code snippets in VSCode?
本文介绍了如何在 VSCode 中添加自定义代码片段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在 Visual Studio Code 中添加自定义代码片段?如果是这样,如何?VSCode 是基于 Atom 的,所以应该是可以的.
解决方案
- 命中 >shift + command + p 并输入片段
- 选择首选项:打开用户片段
- 选择要为其添加自定义代码段的语言类型
- vscode 有注释来解释如何添加代码段,如:>vsdoc
比方说,我们想打开 GO 语言的自定义片段.然后我们可以这样做:
- 命中 >命令 + p
- 输入:go.json + enter 然后你就会进入自定义代码片段页面
<块引用>
片段以 JSON 格式定义并存储在每个用户的 (languageId).json 文件中.例如,Markdown 片段位于 markdown.json 文件中.
使用工具:
Is it possible to add custom code snippets in Visual Studio Code? And if so, how? VSCode is based on Atom, so it should be possible.
解决方案
- Hit > shift + command + p and type snippets
- Select Preferences: Open User Snippets
- Choose the language type for which you want to add the custom snippet
- vscode has comments to explain on how to add a snippet, as described on :> vsdoc
Lets say, we want to open custom snippets for the language GO. Then we can do:
- Hit > command + p
- Type: go.json + enter And you land on the custom snippet page
Snippets are defined in a JSON format and stored in a per-user (languageId).json file. For example, Markdown snippets go in a markdown.json file.
Using tools:
- Snippet Generator extension (recommended)
- Online snippet generator
这篇关于如何在 VSCode 中添加自定义代码片段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文