简体   繁体   English

如何在 JavaScript 中编辑 Visual Studio Code 自动完成功能?

[英]How to edit Visual Studio Code auto-complete in JavaScript?

I was coding on JavaScript when my instructor, Andrew J. Mead (I actually learn JS from Udemy) were telling about try and catch .我在 JavaScript 上编码时,我的导师Andrew J. Mead (我实际上是从 Udemy 学习 JS)正在讲述try 和 catch I type slowly so I often use auto-complete given by VS Code.我打字很慢,所以我经常使用 VS Code 提供的自动完成功能。 Anyway, I wrote try and in auto-complete it gave me trycatch .无论如何,我写了try并在自动完成中给了我trycatch I clicked on it and it gave me this我点击它,它给了我这个

try {

} catch (error) {

}

I want the error to be e like catch(e) , not catch(error) .我希望错误ecatch(e) ,而不是catch(error) Is there any way that I can edit VS Code's auto-complete?有什么方法可以编辑 VS Code 的自动完成功能吗?

Screenshots given给出的截图

  1. trycatch试着抓
  2. auto-complete result自动完成结果
  3. what I want我想要的是

Thanks recently for the support感谢最近的支持

You can create custom snippet for VS Code您可以为 VS Code 创建自定义代码段
For do this, you need:为此,您需要:

  • Open snippet editor for js (open Command Palette (Ctrl-Shift-P) and print "Snippet", and then select "Configure user snippets", select "JavaScript")打开 js 片段编辑器(打开命令面板 (Ctrl-Shift-P) 并打印“片段”,然后 select“配置用户片段”,select“JavaScript”)
  • In the end of json paste:在json粘贴结束:

 {... "My Try-Catch block": { "prefix": "trycatch", "body": [ "try {", "\t$0", "} catch (e) {", "\t", "}", ], "description": "Paste try-catch with e" } }

Your snippet will be up than standard in autocomplete您的代码段将超过自动完成的标准


Or you can edit default snippets located at:或者您可以编辑位于以下位置的默认片段:

%localappdata%\Programs\Microsoft VS Code\resources\app\extensions\javascript\snippets

In javascript.code-snippets filejavascript.code-snippets文件中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM