您现在的位置是:首页 > 文章详情

编写Visual Studio Code插件初尝试

日期:2019-04-22点击:411

参考官方入门: Your First Visual Studio Code Extension - Hello World

源码在: program-in-chinese/vscode_helloWorld

创建插件过程中, 发现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_vscode_run_extension

顺便感受一下调试功能:
2017_12_04_vscode_debug

2017-12-04

原文链接:https://yq.aliyun.com/articles/699479
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章