综述
VSCode可以很方便地编辑用户自定义代码段,即文件
>首选项
>用户代码片段
或直接在命令面板
搜索snippets
,根据示例编写代码段即可。但是我在编写markdown代码段后出现了问题:输入prefix没有自动提示,即markdown没有intellisense功能。
解决方法
- 在
文件
>首选项
>设置
中搜索tabCompletion
选择on
或者onlySnippets
- 或者直接在
settings.json
文件中添加如下代码:
"editor.tabCompletion": "onlySnippets"
然后在编写markdown文件时输入相应的prefix按Tab
键即可插入代码段。
参考
By default, tab completion is disabled. Use the editor.tabCompletion setting to enable it. These values exist:
- off - (default) Tab completion is disabled.
- on - Tab completion is enabled for all suggestions and repeated invocations insert the next best suggestion.
- onlySnippets - Tab completion only inserts static snippets which prefix match the current line prefix.
In Visual Studio Code, snippets show in IntelliSense (Ctrl+Space) mixed with other suggestions as well as in a dedicated snippet picker (Insert Snippet in the Command Palette). There is also support for tab-completion: Enable it with “editor.tabCompletion”: “on”, type a snippet prefix, and press Tab to insert a snippet.