Prerequisites

  • Install Node.js
  • Install the template generator with npm install -g yo generator-code

Generate a VS Code Extensions

  1. Open your terminal and run yo code.
  2. Follow the prompts in the terminal (select the type of the extension, enter a name for the extension, etc.). At the end, a folder with files for the extension is created. prompts
  3. Open the extension folder in VS Code.
  4. Write your commands in the file extensions.js(or extensions.ts depending on the extension type).
  5. Edit the package.json to link your commands from the extension.js with your code. For more information, see npm: package.json.
  6. If yneed to import modules (defined as dependencies in package.json), run the command npm install in the extension folder.
  7. Test the extension by pressing F5, then Crtl+Shift+P to open the command palette and enter the title of your command.

In case of errors, open the Output panel (Ctrl+Shift+U) and select Extension Host from the dropdown to troubleshoot.