当前位置:网站首页>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;
边栏推荐
- zgc的垃圾收集的主要階段
- Insert sort
- #yyds干货盘点# 解决剑指offer:字符流中第一个不重复的字符
- JVisualVM初步使用
- Risk control modeling X: Discussion on problems existing in traditional modeling methods and Exploration on improvement methods
- Yanghui triangle code implementation
- (4) Pyqt designs and implements the [factory production management system] order page - add, delete, modify and query (including source code analysis)
- @loadbalance annotation of resttemplate
- Fill in the checklist & lt; int> Have default values? [repeat] - fill list & lt; int> with default values? [duplicate]
- drf 接收嵌套数据并创建对象, 解决:drf NOT NULL constraint failed
猜你喜欢

Structure knowledge points all in

NiO User Guide

A high-value MySQL management tool

多线程模型下的生产者消费者模式

User guide for JUC concurrency Toolkit

How do complex systems detect anomalies? North Carolina UNCC and others' latest overview of graph based deep learning anomaly detection methods in complex distributed systems describes the latest prog

Compiling process of OpenSSL and libevent on PC

建立高可用的数据库

Smart management of green agriculture: a visual platform for agricultural product scheduling

SQL调优指南笔记6:Explaining and Displaying Execution Plans
随机推荐
JUC并发工具包使用指南
Libmysqlclient A static library
Zip压缩解压缩
Compiling process of OpenSSL and libevent on PC
Bubble sort
Turing prize winner: what should I pay attention to if I want to succeed in my academic career?
Semester summary of freshman year
选择排序
结构体知识点all in
SQL调优指南笔记11:Histograms
zgc 并发标识和并发转移阶段的多视图地址映射
Oracle LiveLabs实验:Introduction to Oracle Spatial
Simple understanding of cap and base theory
Oracle数据库中查询执行计划的权限
linux备份mysql
SQL调优指南笔记12:Configuring Options for Optimizer Statistics Gathering
SQL tuning guide notes 8:optimizer access paths
Recommended Chinese font in the code input box of Oracle SQL developer
同花顺能开户吗,在APP上可以直接开通券商安全吗
[qnx hypervisor 2.2 manuel de l'utilisateur] 4.2 environnement de construction pris en charge