如何编辑现有的 VS Code 片段 [英] How to edit existing VS Code Snippets
问题描述
有没有办法删除或编辑 Visual Studio CODE 中的一些默认代码片段?
Is there a way to remove or edit some of the default code snippets in Visual Studio CODE ?
例如,当我输入 req+TAB 时,我需要 require
而不是 requestAnimationFrame
For example when i type req+TAB i need require
not requestAnimationFrame
推荐答案
建议项 requestAnimationFrame
来自 JavaScript 语言服务.它不是来自片段.
The suggestion item requestAnimationFrame
is coming from the JavaScript language service. It's not coming from the snippets.
但是,您可以定义自己的代码段并告诉 Visual Studio Code 首先显示代码段.怎么做:
However, you can define your own snippets and tell Visual Studio Code to show the snippets first. How to do it:
- 转到<代码>文件 ->首选项 ->User Snippets 并选择 JavaScript 以编辑该语言的代码段
将此条目添加到打开的文件
javascript.json
并保存
- Go to
File -> Preferences -> User Snippets
and select JavaScript in order to edit snippets for that language Add this entry to the opened file
javascript.json
and save it
"require": {
"prefix": "req",
"body": [
"require"
],
"description": "Add 'require'"
}
将以下行添加到您首选的settings.json
(用户或工作区设置)并保存
Add the following line to your preferred settings.json
(user or workspace settings) and save it
"editor.snippetSuggestions": "top"
现在,只要您在 .js
文件中键入 req
,您就会首先获得自定义的 require
建议.
Now you get your self defined require
suggestion in first place as soon as you type req
in a .js
file.
这篇关于如何编辑现有的 VS Code 片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!