iTranslated by AI
Racket: How to Install and Configure Code Runner for Racket Programming
tl;dr
- Install
Code RunnerinVS Code - Configure
Code Runnerto run Racket/Scheme/LISP programs using Racket - Run Racket programs on
VS Code
Thanks to Code Runner, you can run Racket programs from Visual Studio Code .
Enjoy!
1. Introduction
In this article, I will explain in detail how to install Code Runner and configure it to run Racket programs.
1.1. What is Code Runner?
Code Runner is an extension that executes code for various programs within Visual Studio Code .
It supports a wide range of languages such as Python, JavaScript, Java, C#, PHP, Ruby, and Racket is one of them.
When you execute Code Runner, it runs a specified command and outputs the execution results to the Output window.
For example, if the program is a Racket program, it will be racket <source file>.
2. Installing Code Runner
There are two ways to install Code Runner in VS Code : using the [Extensions] menu within VS Code , or via the command line.
Here, I will explain each method.
2.1. Installing Code Runner in VS Code
First, I will explain the steps to install Code Runner within VS Code .
-
Select Extensions:
Click the [Extensions] icon from the left menu (or pressCtrl+Shift+X)

-
Search for
Code Runner:
EnterCode Runnerin the search bar and select the corresponding extension from the search results

-
Install
Code Runner:
Click [Install] to installCode Runner

This completes the installation of Code Runner within VS Code .
2.2. Installing Code Runner from the Command Line
In VS Code , you can install extensions from the command line.
Follow these steps to install Code Runner from the command line.
-
Open
PowerShell:

-
Execute the following command:
code --install-extension formulahendry.code-runner
This completes the installation of Code Runner via the command line.
3. Configuring Code Runner
Code Runner allows you to configure execution commands for each language. To do so, you need to add an "Executor Map" to the VS Code settings file, "settings.json".
3.1. Adding the Executor Map
Follow these steps to add the Executor Map for running Racket programs.
-
Open User Settings:
PressCtrl+Shift+Pand select [Open User Settings] from the command palette.

-
Add Settings:
Add the following settings to "settings.json". This allows you to run Racket/Scheme/LISP programs using Racket.settings.json"code-runner.customCommand": "echo hello", "code-runner.executorMap": { "racket": "racket $fullFileName", "scheme": "racket $fullFileName", "lisp": "racket $fullFileName", },By using
$fullFileNameas shown above, you can specify the source file with its full path. This ensures that the program can be executed regardless of which directory the source file is located in. -
Save Settings:
Save the settings file by pressingCtrl+Sand close it withCtrl+W.
This completes the configuration of the Executor Map.
4. Verifying Code Runner Operation
4.1. Verifying with "Hello World"
In 3.1, we added the settings to run Racket programs. To confirm that these settings are correctly applied, we will create and run a "Hello World" program. Follow the steps below.
-
Create
Hello World:
Create the following program inVS Code.hello.rkt#lang racket (display "Hello, my first racket!") -
Run the Program:
Execute the "hello.rkt" program by pressingCtrl+Alt+Non the source file or right-clicking and selecting [Run Code]. -
Check the Output:
Verify that the following message is displayed in the [Output] window.Hello, my first racket!
If the message you created is output as shown above, Code Runner is operating correctly.
Conclusion
In this article, I introduced how to install Code Runner in Visual Studio Code and configure it to run Racket programs. This makes it easier to verify the operation of Racket programs. I hope you leverage this new knowledge to enjoy the world of Racket programming.
Happy Hacking!
References
Websites
-
VS Code CLI: Official documentation regarding theVS Codecommand line. -
Code Runner: Official GitHub repository forCode Runner.
Discussion