C++ Competitive Programming Boilerplate ⚡

A lightning-fast Visual Studio Code extension designed for competitive programmers and C++ developers. Insert optimized boilerplate templates, fast I/O configurations, and essential CP snippets with a single keypress or prefix.
✨ Features
- 🚀 Multiple Boilerplate Templates: Choose between Standard C++, Competitive Programming (Fast I/O), Test Cases Loop, and Advanced setups.
- ⚡ Auto-Focus Cursor Placement: Cursor automatically drops right into your
solve() or main() function so you can immediately begin coding.
- ⌨️ Quick Keyboard Shortcut: Press
Ctrl+Alt+B (Cmd+Alt+B on macOS) to instantly insert boilerplate into any C++ file.
- 🧩 Smart Snippets: Extensive collection of CP snippets (
cp, cpt, fastio, forr, all, binpow, pbds, etc.).
- ⚙️ Configurable: Set your preferred default template and include your author name automatically.
🚀 How to Use
Method 1: Keyboard Shortcut
Open or create any .cpp or .c file and press:
- Windows / Linux:
Ctrl + Alt + B
- macOS:
Cmd + Alt + B
Method 2: Command Palette
- Open the Command Palette (
Ctrl + Shift + P or Cmd + Shift + P).
- Type
C++: Insert Boilerplate to insert your default template.
- Or type
C++: Select & Insert Template... to pick from a menu of options.
Method 3: Editor Snippets
Type any snippet prefix and press Tab or Enter:
| Prefix |
Description |
cp / cptemplate |
Competitive Programming Boilerplate with Fast I/O & solve() |
cpt / cptest |
CP Boilerplate with multiple test cases loop (t cases) |
cpp / basic |
Minimal standard C++ main() starter |
bits |
#include <bits/stdc++.h> boilerplate |
fastio |
Fast I/O lines (cin.tie(NULL), ios_base::sync_with_stdio(false)) |
forr |
Forward loop: for (int i = 0; i < n; ++i) |
forrev |
Reverse loop: for (int i = n - 1; i >= 0; --i) |
all |
Shorthand for v.begin(), v.end() |
binpow |
Fast modular exponentiation function |
pbds |
GNU C++ Policy-Based Data Structure (ordered_set) |
yesno |
Conditional YES / NO output |
📋 Included Templates
1. Competitive Programming (Default)
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define int long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
void solve() {
// Cursor lands here!
}
int32_t main() {
fastio;
solve();
return 0;
}
2. Competitive Programming with Testcases
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define int long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
void solve() {
// Cursor lands here!
}
int32_t main() {
fastio;
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}
3. Standard C++ Starter
#include <iostream>
using namespace std;
int main() {
// Cursor lands here!
return 0;
}
⚙️ Extension Settings
Configure the extension via VS Code Settings (Ctrl + , / Cmd + ,):
| Setting |
Type |
Default |
Description |
cpp-boilerplate.defaultTemplate |
string |
"competitive" |
Select default template: "competitive", "testcases", "basic", or "advanced". |
cpp-boilerplate.authorName |
string |
"" |
Optional author name displayed in the top header comment. |
📦 Local Installation & Testing
To test this extension locally before publishing:
# Compile and build extension
npm run package
# Package into a .vsix file
npx @vscode/vsce package
# Install into VS Code directly
code --install-extension cpp-boilerplate-1.0.0.vsix
🚀 Publishing to Visual Studio Code Marketplace
- Create a publisher account at Visual Studio Marketplace Management Portal.
- Generate a Personal Access Token (PAT) in Azure DevOps with Marketplace (Acquire & Manage) permissions.
- Update
"publisher" in package.json with your Marketplace publisher ID.
- Run:
npx @vscode/vsce publish
(Or log in once via npx @vscode/vsce login <publisher>)
- Alternatively, upload the generated
.vsix directly on the Marketplace Manage Portal.
📄 License
This extension is licensed under the MIT License.