====== Develop VS Code extension ====== {{template>:meta:template:pageinfo#tpl |desc=Introduce how to develop an extension for VS Code.}} ===== Overview ===== This page only records some of the key steps and commands. If you want to learn more details, please refer to [[https://code.visualstudio.com/api/get-started/your-first-extension|your-first-extension]] to get started. ===== Preparation ===== - Install **[[https://nodejs.org/en|Node.js]] ,** **[[https://git-scm.com/|git]]** and **[[https://www.npmjs.com/|npm]].** - Then install **[[https://yeoman.io/|yeoman]]** and **[[https://www.npmjs.com/package/generator-code|Vs Code generator code]]** with npm command. Below are the installation steps in Linux. sudo apt install nodejs sudo apt install git sudo apt install npm sudo npm install -g yo generator-code ===== Development And Test ===== * Run yo code. \\ This command scaffolds a **TypeScript** or **JavaScript** project ready for development. * Develop your extension. * Press F5 in the **VS Code** editor. This will __compile and run the extension__ in a new Extension Development Host window. * Run the command you designed from the Command Palette (CtrlShiftp) in the new window. I have found a way to develop extensions using **Python**. However, it __was archived__ because the author did not have time to maintain it. Please refer to **[[https://pypi.org/project/vscode-ext/|vscode-ext]].** ===== Generate Extension ===== * Run vsce package in the root directory to package an extension. * Run vsce publish in the root directory to publish an extension. ===== Extension Management ===== * Run code --install-extension /path/to/ext.vsix to install an extension. * Run code --list-extensions to list the ext-id of the installed extensions. * Run code --uninstall-extension ext-id to uninstall an extension. **Example**\\ {{:tools:vscode:how_to:media:img:20230610-094038.png?direct&600}} ===== Useful Links ===== * [[https://code.visualstudio.com/api/references/extension-manifest|Extension-manifest]] \\ The details of some fields in package.json are listed here. * [[https://code.visualstudio.com/api/references/vscode-api|VS Code API]] \\ This page lists all VS Code APIs that you can invoke in your Visual Studio Code extension.