參考官方入門: "Your First Visual Studio Code Extension Hello World" 源碼在: "program in chinese/vscode_helloWorld" 創建插件過程中, 發現identifier和publisher name不允許中文命名( ...
參考官方入門: 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結果:
順便感受一下調試功能: