Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Markdown Code Block RunnerNew to Visual Studio Code? Get it now.
Markdown Code Block Runner

Markdown Code Block Runner

Renat Hossain

|
918 installs
| (1) | Free
Enables the seamless execution of code blocks in any language within Markdown files in VS Code
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Markdown Code Block Runner for VS Code

This extension allows you to execute code blocks in any programming language directly from Markdown/Quarto files in VS Code. Available on Visual Studio Marketplace and Open VSX Registry.

Run Code Block Run Code Snippet Run On Markdown

Features

  • Execute Code Blocks: CodeLens Buttons appear above each code block (```) for running or copying the code. Temporary files are created for execution and are cleaned up afterward.
  • Execute Code Snippets: Run code snippets (enclosed in `) with Ctrl + Click. Results are displayed in the terminal.
  • Save Execution Results: Capture the output of executing a code block directly within the Markdown document.
  • Broad Language Support: Supports a wide range of languages, including C, Rust, C++, Java, TypeScript, PHP, Perl, R, Dart, Groovy, Go, Haskell, Julia, Lua, Ruby, JavaScript, Python, Bash. Add non-compiled languages via settings.

Requirements

Before running a code block:

  • Verify "Compiler Configuration" settings are correct.
  • Ensure your code is correct.
  • Install necessary languages and dependencies.
  • Add compilers to the PATH environment variable if necessary to enable global access to installed languages.
  • For Quarto Support, also download the Quarto VS Code Extension.

On Arch Linux, install all supported languages with:

sudo pacman --needed -S php perl r dart groovy go rustup typescript ghc julia lua ruby nodejs npm python bash

For other systems, research language installation or use the Windows Subsystem for Linux.

Demo File

Download or copy DEMO.md and the demo_helpers folder into VS Code after installing this extension, and test all the features out!

Extension Settings

Compiler Configuration

Configure language compilers by specifying for each Language (Code Block Tag), the following value: [Language Name, File Extension, Compiler Command/Path]. Only non-compiled languages can be added.

// Example
Item: `python`, Value: `["Python", "py", "python"]`

Reset settings using the ↻ icons or remove the markdownRunner.compilerConfiguration entry from VSCode's settings.json to restore to default if any issues occur.

Python Path

Enable to add the Markdown file's parent directory to Python's sys.path, allowing you to import modules from that directory.

Default Codes

Prepend or wrap your code blocks with default code to improve readability, by specifying for each language (Code Block Tag), either the string to be prepended or the -I@ (insert at) flag followed by whitespace and a string containing the @ symbol where you want to insert the code.

// Example
Item: `bash`, Value: `var=123\n`
Item: `cpp`, Value: `-I@ #include <bits/stdc++.h>\nusing namespace std;\nint main(){\n@}\n`
  • The Bash code echo $var is preceded by var=123\n, forming var=123\necho $var, which results in the output 123.
  • The code cout << 456 << endl; is transformed to the following, which outputs 456:
#include <bits/stdc++.h>
using namespace std;
int main(){
cout << 456 << endl;
}

Activate On Quarto

Enable to activate the extension on Quarto (.qmd) files.

Future Development

Planned features (no guarantee):

  • Support for multiple Run on Markdown output streams.

Your feedback and contributions are welcome in shaping the future of this extension!

License

GPL-3.0 license

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft