Reading macro-heavy C++ code can be frustrating, especially for beginners. Competitive programmers often use macros to shorten code, but this can make solutions difficult to read and understand.
Wouldn’t it be easier if macros were automatically replaced with standard C++ for easier understanding? That’s exactly what Competitive Code Refactor, a free VS Code extension, does.
Competitive Code Refactor is a VS Code extension that automatically expands macros into standard C++ syntax, making code more readable.
Key Features:
1. Replaces macros with equivalent C++ loops and expressions.
2. Removes unnecessary #define
lines for a cleaner codebase.
3. One-click refactoring with a dedicated button in the VS Code sidebar.
Why Use It?
Many competitive programmers use macros to write concise code, but:
- Beginners struggle to understand them.
- Debugging becomes harder when macros obscure logic.
- Reading others' code can be challenging.
How to Install
Installing the extension is simple:
1. Open VS Code.
2. Go to the Extensions panel (**Ctrl + Shift + X**).
3. Search for "Competitive Code Refactor".
4. Click Install.
Example Usage
Before Refactoring:
#define rep(i, a, b) for(int i = a; i < (b); i++)
rep(i, 0, n) cin >> a[i];
After Refactoring:
for(int i = 0; i < (n); i++) cin >> a[i];
No more manually expanding macros—just click and refactor!
Try It and Share Your Feedback
Link of extension : Competetive Code Refactor
How to use?
After installing follow the figure.
Have suggestions? Found a bug? Let me know in the comments! Your feedback is valuable.