VSCode Setup for Competitive Programming
Note
- Programming Languages Covered: C, C++, Java, Python
- Code Editor: Visual Studio Code (VSCode)
- Compatible Operating Systems: Windows, Linux, macOS
Installing Programming Languages
If you're solving problems on platforms like CodeChef, Codeforces, or Spoj, you may be using online compilers. However, this can be cumbersome due to the need to constantly switch tabs to copy and modify test cases. Programming in your own IDE offers numerous advantages, such as IntelliSense for code completion and no latency issues.
Additionally, online compilers like Ideone may expose your code publicly, potentially leading to plagiarism. To avoid these issues, setting up your local environment is highly recommended.
Python 3 Installation
For Windows, installing Python is straightforward. Download the installer from the official Python website and run it. Ensure you check the "Add Python to PATH" option during installation.
GCC Setup for C and C++
GCC is the standard compiler for C and C++. For Linux, GCC can be easily installed through your package manager. For Windows, you can use MinGW, which provides GCC builds.
Steps to Install MinGW:

package view
- Download MinGW.
- After installation, open the MinGW package manager.
- Mark all the packages with a green tick for installation.
- Click on the “Installation” menu and select “Apply Changes.”
- Wait for the installation to complete.
Adding GCC to Environment Variables:

windows environment variables

mingw environment variables setup
- Open the environment variables settings by searching for it in the Start menu.
- Add the following paths:
-
C:\MinGW\bin
-
C:\MinGW\mingw32\bin
-
C:\MinGW\lib\gcc
-
Java Setup
- Download the latest JDK from Oracle's official site.
- Install the appropriate installer for your system (e.g., x64 Installer for Windows, ARM64 DMG Installer for macOS).
- Add Java to your environment variables by adding the path:
C:\Program Files\Java\jdk-20\bin
Installing VSCode
Visual Studio Code (VSCode) is a versatile tool for competitive programming. It provides a customizable environment for coding in multiple languages like C++, Python, and more. Download VSCode from here.
Installing Essential Extensions
Start by installing the following key extensions:
- C/C++ by Microsoft: Provides IntelliSense, debugging, and code browsing.
- Python: Offers IntelliSense, linting, and debugging for Python.
- Code Runner: Allows quick execution of code.
- Competitive Programming Helper: Automates input/output handling, improving productivity.
Setting Up Code Runner for the Terminal
- Install the Code Runner extension and restart VSCode.
- Open VSCode settings with Ctrl + ,
- Search for "Code-runner: Run In Terminal" and enable it, or add
"code-runner.runInTerminal": true
insettings.json
Optional Configuration
If you want to remove .exe
and .class
files after execution, follow these steps:
- Press F1 or Ctrl + Shift + P to open "Preferences: Open User Settings (JSON)."
- Add the following under
"code-runner.executorMap"
:
"java": "cd $dir && javac $fileName && java $fileNameWithoutExt && rm $fileNameWithoutExt.class",
"cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt && rm $fileNameWithoutExt.exe",
"c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt && rm $fileNameWithoutExt.exe"
Running Code in VSCode
To run a file (C, C++, Java, or Python), press Ctrl + Shift + N. For macOS, the shortcuts are similar, use ⌘ Command + Shift + N.
For Linux, the same shortcut Ctrl + Shift + N is typically used.
With this setup, your competitive programming experience will be smoother and more efficient, allowing you to focus on solving problems rather than wrestling with your tools.