Visual Studio Code has become the default editor for a growing number of developers: data pipelines, version control, multi-language projects, and infrastructure tooling all live comfortably in a single environment. The new FICO Xpress Mosel extension, in beta release, brings comprehensive language support for the latest version of Mosel directly inside VS Code:
The extension activates automatically whenever a .mos file is open in the editor. No manual configuration is needed to start using language features right away. Runtime features (compile, run, debug) require a valid Xpress installation; see Installation Guidelines below.
As an example: prime.mos takes a LIMIT parameter that controls the upper bound for prime number search. To compile it first and then launch a debug session with a custom limit, define both steps in .vscode/tasks.json:
Once Xpress is installed:
Try it yourself: install the extension from the VS Code Marketplace and open any Mosel model from your Xpress installation. As this is a beta release, your feedback is invaluable; share your thoughts, report issues, or suggest features in the comments below.
Subscribe to the FICO Xpress Optimization Blog for more content on Mosel, optimization, and the latest Xpress features.
- Syntax highlighting
- Code completion
- Inline documentation
- Jump-to-definition across files
- Real-time diagnostics from the Mosel parser
- Full debugging experience
Getting Started: Installing the Extension
To install, open the Extensions view in VS Code (Ctrl+Shift+X) and search for "FICO Xpress Mosel (BETA)", then click Install. Make sure Auto Update is enabled, so you always receive the latest fixes and features.The extension activates automatically whenever a .mos file is open in the editor. No manual configuration is needed to start using language features right away. Runtime features (compile, run, debug) require a valid Xpress installation; see Installation Guidelines below.
Intelligent Language Support
The extension provides a set of features that enhance the development experience for Mosel users, including:- Syntax Highlighting: Clear and colorful code visualization according to Mosel grammar: keywords, string literals, numeric constants, comments, annotations, and identifiers each receive distinct visual treatment.
- Code Folding: Collapse and expand blocks such as parameters, declarations, initializations, procedure, and function for better readability and focus. Click the arrow in the editor gutter to fold and unfold.
- Jump to Definition: Place the cursor on any symbol and press F12 (or right-click and select Go to Definition) to jump instantly to its declaration. Works across files too, for any file linked via uses, import, or include.
- Inline Help (across files): Hover over subroutines, keywords, or entity names to get inline documentation and declaration details. Hovering over run in runprimedistr.mos, for example, shows the full mmjobs signature and description inline, without leaving the current file.
- Code Completion: Suggestions from the Mosel language reference and your local declarations. Built-in functions appear with full signatures and rich documentation in the detail panel — including multiple overloads where applicable. Works across files for any module linked via uses, import, or include.
- Diagnostics: Real-time syntax error feedback from the Mosel parser. Errors and warnings appear inline, underlined at the offending token, without triggering a full compile run.
Runtime & Debugging Tools
The extension adds two entry points for running and debugging Mosel files:- A play button in the editor title bar whenever a .mos file is active, opening a quick menu to compile, run, or debug the current file.
- All commands are also available in the command palette (Ctrl+Shift+P).
The following commands are available:
- Compile Mosel Files: Compile Mosel source files into a portable binary (.bim) format.
- Run Mosel Files: Execute Mosel models with live output in a VS Code terminal.
- Debug Mosel Files: Full debugging support as described next.
A Closer Look at Debugging
Debugging optimization models supports understanding not just the code flow, but also the state of decision variables, constraints, and data structures at each step. The extension's debugger supports VS Code's Debug view, giving you a familiar interface to:- Set breakpoints anywhere in your Mosel code, including conditional breakpoints that trigger only when specific conditions are met (e.g., when a loop index reaches a certain value)
- Inspect variables in the Variables pane and the dedicated Variable Inspector panel, which expands Mosel sets and arrays into their individual elements alongside their indices
- Step through execution line by line, stepping into or over subroutine calls to trace the logic of your model
- Evaluate expressions on the fly using the Debug Console. This supports arithmetic expressions and certain Mosel built-in functions — for example, getsize(SPrime) returns the current size of the set, or 2 * LIMIT evaluates an arithmetic expression against live model state, without modifying your code
Code Formatting and Configurable Language Settings
You can define external Mosel source folders to extend language support to files outside the current workspace, or customize formatting options at the project level. To do so, open the User Settings JSON (Ctrl+Shift+P -> Open User Settings (JSON)) and add:The indexer-resolved-folders entry accepts both relative and absolute paths. The code-format-options entry controls how the formatter applies whitespace. Use Format Document (Shift+Alt+F) to apply it on demand. To apply formatting automatically on every save, add "editor.formatOnSave": true to your VS Code settings. If you have other formatters installed (such as Black for Python), you may need to explicitly set the Mosel formatter as the default for .mos files by adding "[mosel]": { "editor.defaultFormatter": "fico-xpress.fico-xpress-mosel" } to your User Settings JSON.
Automate Development Workflows with Custom Tasks
The extension enables custom tasks that can be executed from the command palette to compile, debug, or run files that require command-line arguments, trigger test runners, or chain multiple steps together.As an example: prime.mos takes a LIMIT parameter that controls the upper bound for prime number search. To compile it first and then launch a debug session with a custom limit, define both steps in .vscode/tasks.json:
Running Debug prime from the command palette (Ctrl+Shift+P -> Tasks: Run Task) triggers the chain automatically: VS Code compiles prime.mos first (with debug information), then starts a debug session with LIMIT set to 1000. This pattern scales to more complex workflows where a model depends on pre-compiled packages or requires specific parameter combinations across multiple scenarios.
Installation Guidelines
The compile, run, and debug features require a valid installation of FICO Xpress Optimization Suite. Language features (highlighting, completion, hover, diagnostics) work without Xpress. If you are a new user, the FICO Xpress Community License provides free access to Xpress Mosel and to a size-limited version of the optimizer.Once Xpress is installed:
- Ensure the XPRESSDIR environment variable points to your Xpress installation directory. The installer sets this automatically on Windows; on macOS and Linux, add it to your shell profile if not already set.
- Open the Extensions view (Ctrl+Shift+X), search for "FICO Xpress Mosel (BETA)", and click Install.
- Open any .mos file; the extension activates automatically.
Conclusion
The FICO Xpress Mosel extension brings real language intelligence to Mosel inside VS Code: errors caught as you type, instant navigation across files, an integrated debugger with the Variable Inspector and a Debug Console that supports the full set of Mosel debugger expressions, and task automation for repeatable build and debug workflows.Try it yourself: install the extension from the VS Code Marketplace and open any Mosel model from your Xpress installation. As this is a beta release, your feedback is invaluable; share your thoughts, report issues, or suggest features in the comments below.
Subscribe to the FICO Xpress Optimization Blog for more content on Mosel, optimization, and the latest Xpress features.
Updated 4 months ago
Version 3.0FICO
Community Manager
Joined July 21, 2025
FICO® Xpress Optimization Blog
Follow this blog board to get notified when there's new activity