My Code Snippets — VS Code Extension
A VS Code extension to quickly insert, browse, and copy your pre-saved code snippets.
📁 Project Structure
my-codes-extension/
├── package.json ← Extension manifest (name, commands, keybindings)
├── extension.js ← Main logic (do NOT edit unless you know what you're doing)
├── codes.js ← ✏️ YOUR FILE — add all your code snippets here
└── README.md ← This file
✏️ Step 1 — Add Your Codes to codes.js
Open codes.js and add your snippets in this format:
{
name: "Snippet Display Name",
description: "One-line description",
language: "c", // c | cpp | python | java | javascript | assembly
category: "COA", // any label: COA | OS | DS | CN | DBMS | etc.
code: `your code here` // use backtick template literal
}
Example:
{
name: "Booth's Algorithm",
description: "Booth's multiplication in C",
language: "c",
category: "COA",
code: `#include<stdio.h>
int main() {
// your code
return 0;
}`
}
Add as many snippets as you want, separated by commas.
🛠️ Step 2 — Install Prerequisites (one time only)
Make sure you have Node.js installed: https://nodejs.org
Then install the VS Code Extension packager globally:
npm install -g @vscode/vsce
📦 Step 3 — Package the Extension into a .vsix File
Open a terminal in the my-codes-extension/ folder and run:
vsce package
This creates a file like my-codes-extension-1.0.0.vsix in the same folder.
Note: If you get a warning about missing README.md or repository, just press Enter to continue.
🚀 Step 4 — Install the Extension in VS Code
Option A — Drag and drop:
Drag the .vsix file into the VS Code window.
Option B — Command line:
code --install-extension my-codes-extension-1.0.0.vsix
Option C — VS Code UI:
- Open VS Code
- Go to Extensions panel (
Ctrl+Shift+X)
- Click the
··· menu (top right of Extensions panel)
- Choose "Install from VSIX..."
- Select your
.vsix file
⌨️ Step 5 — Use It!
| Action |
How |
| Insert a snippet |
Press Ctrl+Shift+C (or Cmd+Shift+C on Mac) |
| Browse by category |
Open Command Palette (Ctrl+Shift+P) → type Browse My Codes |
| Copy a snippet |
Open Command Palette → type Copy My Code |
🔄 Updating Your Codes
- Edit
codes.js — add/remove/change snippets
- Run
vsce package again
- Reinstall the new
.vsix (VS Code will auto-update it)
🏷️ Changing the Extension Name / Publisher
Edit package.json:
"name" — internal ID (no spaces, lowercase)
"displayName" — what shows in VS Code
"publisher" — your name/handle
"version" — bump this when you repackage (e.g. 1.0.0 → 1.1.0)