编写Visual Studio Code插件初尝试
发布日期:2021-06-29 15:30:22 浏览次数:3 分类:技术文章

本文共 788 字,大约阅读时间需要 2 分钟。

参考官方入门:

源码在:

创建插件过程中, 发现identifier和publisher name不允许中文命名(报错: invalid xxx):

? What type of extension do you want to create? New Extension (TypeScript)? What's the name of your extension? 吃了么? What's the identifier of your extension? hello? What's the description of your extension? 吃了么? What's your publisher name (more info: https://code.visualstudio.com/docs/tools/vscecli#_publishing-extensions)? nobody

运行一下Hello World命令, 没问题.

按入门教程替代extension.sayHello命令的内容, 实现显示选中文本长度的演示功能:

var 编辑器 = vscode.window.activeTextEditor;        if (!编辑器) {
return; // 无打开的编辑器 } var 选中部分 = 编辑器.selection; var 文本 = 编辑器.document.getText(选中部分); // 显示信息框 vscode.window.showInformationMessage('选中字符数: ' + 文本.length);

运行Hello World结果:

2017_12_04_运行

顺便感受一下调试功能:

2017_12_04_调试

转载地址:https://codeinchinese.blog.csdn.net/article/details/85815349 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:JavaScript实现ZLOGO子集: 前进+转向
下一篇:编程语言试验之Antlr4+JavaScript实现"圈4"

发表评论

最新留言

路过,博主的博客真漂亮。。
[***.116.15.85]2024年04月24日 07时33分45秒