The C++ Button README
August 31, 2025 ยท View on GitHub
๐ The C++ Button is a simple VS Code extension that provides a quick way to compile and run all .cpp files, Python, and Java programs in your current workspace folder. Perfect for developers looking to speed up their workflow!
Features
-
Compile and Run C++ Files: With a single click or command, compile all
.cppfiles in the current workspace and run the main program, saving all files before compiling, which is configurable through settings. -
Compile and Run Java Programs: Automatically detects the main Java class, compiles all
.javafiles, and runs the main program, saving all files before compiling, which is configurable through settings. The compiled.classfiles will be stored in a "build" folder created in your workspace. -
Compile and Run Python File: Execute the currently open Python file directly from the editor, saving the file before execution, which is configurable through settings.
-
Run TypeScript: Run
npm run startfor typescript projects. -
Custom Button: Adds a custom button in the editor for
.cppand.javafiles, allowing fast access to compilation and execution. -
Error Handling: Displays compilation and runtime errors directly in VS Code.
-
Running Time and Memory Usage: Displays the run time and memory usage after each compilation and run. This can be disabled in the settings (enabled by default).
-
Header Comment Generation: Easily add a standardized header comment to your code files, including fields for author name, creation date, file name, project name, and a description.
Usage
C++ Code
- Open one or multiple C++ files in your VS Code workspace.
- Use the Command Palette (Cmd+Shift+P or Ctrl+Shift+P) and search for ๐ Run C++ ๐ป to compile and run your C++ files.
- Alternatively, click the Run C++ button in the editor title when viewing a
.cppfile.
Java Code
- Open one or multiple Java files in your VS Code workspace.
- Ensure one of your Java files contains the
public static void main(String[] args)method. - Use the Command Palette (Cmd+Shift+P or Ctrl+Shift+P) and search for ๐ Run Java โ to compile and run your Java program.
- Alternatively, click the Run Java button in the editor title when viewing a
.javafile.
Python Code
- Open the Python file you want to execute in your VS Code workspace.
- Use the Command Palette (Cmd+Shift+P or Ctrl+Shift+P) and search for ๐ Run Python ๐ to execute the currently open Python file.
- Alternatively, click the Run Python button in the editor title when viewing a
.pyfile.
Adding Header Comments
- Open the file you want to add a header comment to.
- Use the Command Palette (Cmd+Shift+P or Ctrl+Shift+P) and search for "๐ Generate Header" to insert a header comment at the top of your code file.
- You can customize the author name through the extension settings.
Customization
- To change the author name for header comments, go to File > Preferences > Settings (or press
Ctrl (Cmd) + ,), then search for "The C++ Button Configuration" and update the Author Name setting.
Requirements
-
C++: Ensure
g++is installed and available in your PATH. This extension usesg++to compile C++ files. -
Java: Ensure the Java Development Kit (JDK) is installed and available in your PATH. This extension requires the JDK to compile and run Java files.
-
Python: Install Python and ensure the
python3command is available in your system's PATH. -
VS Code: Version 1.94.0 or higher.