当前位置:网站首页>How to write a vscode plug-in by yourself to realize plug-in freedom!
How to write a vscode plug-in by yourself to realize plug-in freedom!
2022-06-12 21:42:00 【Koi】
One 、 Environment building
1、 install Visual Studio Code
2、 install Node.js
3、 install Git
4、 Install tools for producing plug-in code :Yeoman and VSCode Extension generator
- open cmd Command line tools , Perform the following installation Yeoman and VSCode Extension generator
npm install -g yo generator-code
Two 、 Create a project
1、 stay cmd Execute the following command from the command line , Automatically generate the basic code of a project
yo code

2、 Option explanation :
- Choose the language for writing extensions , I chose JavaScript
- Enter the extension name
- Enter a flag ( I choose the default directly )
- Enter a description of the extension
- stay jsconfig.json Whether to enable javascript Type checking
- Bind or not git Warehouse
- Which package manager to use ( I choose the npm)
3、 Directory description 
4、 Result display
- The project is based on F5 perhaps vscode menu bar :“ function – Start debugging ”, Then a new workspace window will open
- Shortcut key Ctrl+shift+p, Input hello word, The corresponding content will pop up


3、 ... and 、 Modify the code , Make a statistic of the number of characters in the selection code
1、 stay package.json Add the relevant code in 
2、 stay extension.js Add relevant codes to the file 
3、 External file wordCounter.js file
class WordCounter {
constructor(_vscode) {
// Constructors , Pass in vscode object
this.vscode = _vscode;
this.init();
}
init() {
// initialization
var vscode = this.vscode;
var StatusBarAlignment = vscode.StatusBarAlignment;
var window = this.vscode.window;
//statusBar, It needs to be released manually
this.statusBar = window.createStatusBarItem(StatusBarAlignment.Left);
// An array that matches the registration event , Registration of events , It also needs to be released
var disposable = [];
// The event is registered , Will automatically fill in a callback dispose To array
window.onDidChangeTextEditorSelection(this.updateText, this, disposable);
// Save the resources to be released
this.disposable = vscode.Disposable.from(disposable);
this.updateText();
this.statusBar.show();
}
updateText() {
var window = this.vscode.window;
this.editor = window.activeTextEditor;
var content = this.editor.document.getText();
var len = content.replace(/[\r\n\s]+/g, '').length;
this.statusBar.text = ` Already knocked ${
len} A character. `;
}
dispose() {
// Realization dispose Method
this.disposable.dispose();
this.statusBar.dispose();
}
}
module.exports = WordCounter;
边栏推荐
- Main stages of garbage collection in ZGC
- 如何自己动手写一个vscode插件,实现插件自由!
- SQL调优指南笔记9:Joins
- Icml2022 | galaxy: active learning of polarization map
- 递归调用知识点-包含例题求解二分查找、青蛙跳台阶、逆序输出、阶乘、斐波那契、汉诺塔。
- C language learning notes (II)
- Solve one-dimensional array prefix sum
- Teamwork collaboration application experience sharing | community essay solicitation
- Digital intelligence data depth | Bi goes down the altar? It's not that the market has declined, it's that the story has changed
- GNS安装与配置
猜你喜欢

Teamwork collaboration application experience sharing | community essay solicitation

A high-value MySQL management tool

Graphics2D类基本使用
![[target detection] |dive detector into box for object detection new training method based on fcos](/img/ac/c54c2733dceffea086b772f35f128a.png)
[target detection] |dive detector into box for object detection new training method based on fcos

Cookies and sessions

MySQL master-slave replication

Pixel level reconstruction and restoration technology to solve severe image blur

“Oracle数据库并行执行”技术白皮书读书笔记

复杂系统如何检测异常?北卡UNCC等最新《复杂分布式系统中基于图的深度学习异常检测方法综述》,阐述最新图异常检测技术进展

MySql主从复制
随机推荐
SQL调优指南笔记6:Explaining and Displaying Execution Plans
Exception encountered by selenium operation element
Oracle 19C installation documentation
SQL调优指南笔记15:Controlling the Use of Optimizer Statistics
DRF receives nested data and creates objects. Solution: DRF not NULL constraint failed
Insert sort
Yanghui triangle code implementation
Simple understanding of cap and base theory
makefile 的ifeq,filter,strip 简单使用
User guide for JUC concurrency Toolkit
#yyds干货盘点# 解决剑指offer:字符流中第一个不重复的字符
有向图深拷贝
Oracle livelabs experiment: introduction to Oracle Spatial
PCB封装下载网站推荐及其详细使用方法
风控建模十:传统建模方法存在的问题探讨及改进方法探索
Design and practice of Hudi bucket index in byte skipping
选择排序
Semester summary of freshman year
在同花顺开户证券安全吗,证券开户怎么开户流程
阅读笔记 Deep Hough Voting for 3D Object Detection in Point Clouds