I was tired of switching between terminal tabs to run code snippets. Python here, JavaScript there, Rust somewhere else. So I built a VS Code extension that handles all of them.
The extension is called Code Runner. It adds a run button to your editor that executes the current file using the right compiler or interpreter. It supports 40+ languages out of the box.
The hardest part was abstracting language-specific execution into a unified interface. Each language has different compiler flags, execution patterns, and error formats. Python runs directly. C++ needs compiling first. Rust has cargo. TypeScript needs ts-node or a build step.
I settled on a configuration-driven approach. The extension ships with default profiles for each language. Users can override any of them through VS Code settings. This gives beginners a zero-config experience while letting power users customize everything.
The output panel was another challenge. I wanted syntax-highlighted results with inline error markers. VS Code's output channel is plain text only. I ended up building a custom WebView-based output panel that formats results with proper highlighting.
Error handling is where most code runners fall short. If your Python script throws a traceback, the extension parses it and creates problem markers at the correct lines. You can navigate errors with F8 just like regular compiler errors.
The extension has been downloaded a few thousand times. The most common feedback is that it works when nothing else does. That's the best compliment a developer tool can get.
I learned more about child process management and cross-platform compatibility from this project than from any tutorial. Things like resolving PATH variables differently on Windows, handling spaces in file paths, and managing long-running processes gracefully.
If you want to see the full source code or read about my other projects, visit my portfolio at nishantunavane.qzz.io.
Check out the Project
If you want to see the full source code or contribute, you can find the repository here:
(Optional: If your repo is public, use the embed below instead!)
IamNishant51
/
CODE-RUNNER-vscode-extension
extension for vs code to run c and c++ programms inside vs code without any online compiler or switching tabs
VS Code Code Runner Extension 🚀
A powerful VS Code extension that allows you to run C, C++, and Python code directly within VS Code without switching between applications or using online compilers.
Features ✨
- Multi-language Support: Run C, C++, and Python code seamlessly
- Real-time Output: View program output directly in VS Code
- Interactive Input: Support for program input during execution
- Clean Interface: Modern and intuitive user interface
- File Management: Automatic file handling and cleanup
- Cross-platform: Works on Windows, Linux, and macOS
Prerequisites 🛠️
Ensure you have the following installed:
- Visual Studio Code
- For C/C++: GCC/G++ compiler
- For Python: Python interpreter
- Required extensions dependencies will be automatically installed
Installation 📥
- Open VS Code
- Go to Extensions (Ctrl+Shift+X)
- Search for "Code Runner"
- Click Install
Usage 💻
- Open your code file in VS Code
- Click the "Code Runner" icon in the activity bar
- Enter your file…
I’m curious—how do you usually handle running snippets quickly? Do you stick to the terminal, or have you customized your IDE for specific languages? Let me know in the comments!
Top comments (0)