当前位置:网站首页>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;
边栏推荐
- Kdd2022 | graphmae: self supervised mask map self encoder
- SQL调优指南笔记17:Importing and Exporting Optimizer Statistics
- ICML2022 | GALAXY:極化圖主動學習
- Jdbctemplate inserts and returns the primary key
- Fill in the checklist & lt; int> Have default values? [repeat] - fill list & lt; int> with default values? [duplicate]
- Design and practice of Hudi bucket index in byte skipping
- atoi超强解析
- Common error in script execution: build sh: caller: not found
- ORM implements the mapping relationship between classes and tables, class attributes and fields
- PCB封装下载网站推荐及其详细使用方法
猜你喜欢

Oracle SQL Developer的代码输入框中推荐使用的中文字体

Recommended Chinese font in the code input box of Oracle SQL developer

Kdd2022 | graphmae: self supervised mask map self encoder

SQL调优指南笔记16:Managing Historical Optimizer Statistics

SQL调优指南笔记13:Gathering Optimizer Statistics

ICML2022 | GALAXY:極化圖主動學習

SQL tuning guide notes 9:joins

JUC并发工具包使用指南

ASCII code comparison table

SQL调优指南笔记15:Controlling the Use of Optimizer Statistics
随机推荐
Experiment 7-2-6 print Yanghui triangle (20 points)
Oracle 19c 安装文档
数据批量写入
多线程模型下的生产者消费者模式
ASCII 码对照表
Vagrantbox reinstalling the vboxsf driver
Teamwork collaboration application experience sharing | community essay solicitation
zgc的垃圾收集的主要階段
Digital intelligence data depth | Bi goes down the altar? It's not that the market has declined, it's that the story has changed
Smart management of green agriculture: a visual platform for agricultural product scheduling
六月集训(第11天) —— 矩阵
SQL调优指南笔记17:Importing and Exporting Optimizer Statistics
[QNX hypervisor 2.2 user manual] 4.2 supported build environments
杨辉三角代码实现
冒泡排序
RestTemplate的@LoadBalance注解
Solution of good number pairs
Insert sort
Permission to query execution plan in Oracle Database
Design and practice of Hudi bucket index in byte skipping