如何编辑现有的VS代码段 [英] 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时,我需要要求
不是 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:
- 转到
文件->首选项->用户代码段
,然后选择 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
。
Now you get your self defined require
suggestion in first place as soon as you type req
in a .js
file.
这篇关于如何编辑现有的VS代码段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!