Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Mojo 🔥New to Visual Studio Code? Get it now.
Mojo 🔥

Mojo 🔥

Modular

modular.com
|
101,149 installs
| (12) | Free
Mojo language support
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Mojo for Visual Studio Code

This VS Code extension from the Modular team adds support for the Mojo programming language.

Features

  • Syntax highlighting for .mojo and .🔥 files
  • Code completion
  • Code diagnostics and quick fixes
  • Full LSP experience for doc string code blocks
  • Go to symbol
  • API docs on hover
  • Code formatting
  • Run Mojo file

Get started

  1. Install the Mojo SDK.
  2. Install the Mojo VS Code extension.
  3. Open any .mojo or .🔥 file.

Configuration

The extension will attempt to find the path of the Mojo SDK installation using the MODULAR_HOME environment variable. If MODULAR_HOME is not set within the environment, the path can be explicitly set via the mojo.modularHomePath extension setting.

{
  "mojo.modularHomePath": "/absolute/path/to/.modular"
}

Mojo SDK Resolution

Whenever you want to execute an action on a file, the extension will look for a suitable Mojo SDK that can serve it. The search will start with the mojo.modularHomePath setting of the file's Workspace, if available. Otherwise, the extension will try the to use the same setting but at the User-level. Then, it will try to use the MODULAR_HOME environment variable. If none of these attempts works, the extension will fall back to use the mojo.modularHomePath setting defined at the Workspace-level of any open Workspaces in the current window. This is particularly useful if the user opens Mojo files that don't belong to any active Workspace and wants to get some extension support.

Debugger

A fully featured LLDB debugger is included with Mojo. You can press the down arrow next to the ▶️ button in the top right of a Mojo file, and select Debug Mojo File:

debugging

The default key is F5, and you can rebind the related hotkeys in Preferences: Open Keyboard Shortcuts > Debug: Start Debugging

Code Completion

To trigger a completion press ctrl + space, pressing ctrl + space again will bring up doc hints:

completion

Rebind the hotkey in Preferences: Open Keyboard Shortcuts > Trigger Suggest

Hover and Doc Hints

Hover over a symbol with your cursor for doc hints. The default hotkey to trigger it in macOS is ⌘ + k, ⌘ + i or ctrl + k, ctrl + i in Linux and Windows:

hover

Rebind the hotkey in Preferences: Open Keyboard Shortcuts > Show or Focus Hover

Signature Help

Mojo provides function overloading, so you need a way to scroll through the multiple signatures available. You can bring this up with the hotkey ⌘ + shift + space in macOS or ctrl + shift + space in Linux or Windows.

signature-help

Rebind related hotkeys in Preferences: Open Keyboard Shortcuts > Trigger Parameter Hints

Code Diagnostics

Code diagnostics are indicated with an underline on the code and details appear when you hover. You can also see them in the PROBLEMS tab and use Go to Next Problem in Files to quickly cycle through them:

diagnostics2

Rebind related hotkeys in Preferences: Open Keyboard Shortcuts > Go to Next Problem...

Tip: Also try the Error Lens extension (not associated with Modular), which will display the first line of the diagnostic inline, making it easier to quickly fix problems.

Doc String Code Blocks

Unique to Mojo, you get a full LSP experience for code blocks inside doc strings, with all the features mentioned here including completions and diagnostics:

doc-lsp

Go to Symbol

You can quickly jump to a symbol in the file with ⌘ + shift + o in macOS or ctrl + shift + o in Linux and Windows.

go-to-symbol

This also enables the outline view in the explorer window.

Rebind the hotkey in Preferences: Open Keyboard Shortcuts > Go to Symbol in Editor

Quick Fix

If there is an available quick fix with the code diagnostic, click the lightbulb icon or use the default hotkey ctrl + . for a list of options:

quick-fix

Rebind the hotkey in Preferences: Open Keyboard Shortcuts > Quick Fix...

Run Mojo File

The extension provides a set of actions on the top-right of a Mojo file to run the active file, which by default are under a small ▶️ button up the top-right of the editor:

run-file

These actions are also available in the command palette and under the Mojo submenu in the File Explorer when right-clicking on Mojo files:

right-click-menu

You may bind hotkeys to any of the actions listed here. For example, to bind a hotkey for the "Run Mojo File" action, open preferences, then select Keyboard Shortcuts > Mojo: Run Mojo File.

Run Mojo File

This executes the current Mojo file in a terminal that is reused by other invocations of this same action, even if they run a different file.

Run Mojo File in Dedicated Terminal

This executes the current Mojo file in a dedicated terminal that is reused only by subsequent runs of this very same file.

Code Formatting

From the command palette run Format Document or tick the setting Format on Save:

format

Restarting Mojo Extension

The extension may crash and produce incorrect results periodically, to fix this from the command palette search for Mojo: Restart the extension

restart

Bind a hotkey in Preferences: Open Keyboard Shortcuts > Mojo: Restart the extension

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