Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>IBM CPLEX OPLNew to Visual Studio Code? Get it now.
IBM CPLEX OPL

IBM CPLEX OPL

vlkong

|
4 installs
| (1) | Free
Syntax highlighting for IBM CPLEX Optimization Programming Language (OPL) .mod, .dat, and .oplproject files
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

OPL Language Support for Visual Studio Code

Syntax highlighting and language support for IBM ILOG CPLEX Optimization Programming Language (OPL) files in Visual Studio Code.

Features

This extension provides comprehensive syntax highlighting and execution support for:

  • .mod files - OPL Model files containing optimization models
  • .dat files - OPL Data files containing data definitions and database connections
  • Run OPL Models - Execute .mod files directly from VS Code with F5

Editor Features

  • Bracket Matching: Automatic matching for {}, [], (), <>, #[]#, #<>#
  • Auto-Closing Pairs: Automatically closes brackets, quotes, and special OPL constructs
  • Comment Toggling: Use Ctrl+/ (or Cmd+/ on Mac) to toggle line comments
  • Code Folding: Fold code blocks and regions
  • Smart Indentation: Automatic indentation based on OPL syntax

Installation

From VSIX (Local Installation)

  1. Download the .vsix file
  2. Open VS Code
  3. Go to Extensions view (Ctrl+Shift+X or Cmd+Shift+X)
  4. Click the ... menu at the top of the Extensions view
  5. Select "Install from VSIX..."
  6. Choose the downloaded .vsix file

From Source

  1. Clone this repository
  2. Open the folder in VS Code
  3. Press F5 to launch a new VS Code window with the extension loaded

Usage

Once installed, the extension automatically activates when you open .mod or .dat files. The syntax highlighting will be applied based on your current color theme.

Running OPL Models

You can execute OPL models directly from VS Code:

  1. Press F5 while editing a .mod file to run it with OPL
  2. The extension will automatically:
    • Save the file if it has unsaved changes
    • Look for a corresponding .dat file with the same name
    • Execute oplrun with both the .mod and .dat files (if .dat exists)
    • Display the output in the integrated terminal

OPL Projects View

The extension provides an OPL Projects view in the VS Code sidebar for managing .oplproject configuration files. This view allows you to organize and execute your OPL projects with their associated model and data files.

Key Features:

  • View all .oplproject files in your workspace in a tree structure
  • Run configurations directly from the view by clicking the play button (▶️) next to any config
  • Delete configurations by right-clicking on any config and selecting "Delete Configuration"
  • Quick access to your project configurations without navigating through the file system

To activate the OPL Projects view:

  1. Open the VS Code sidebar (Ctrl+B or Cmd+B)
  2. Look for the OPL Projects icon in the Activity Bar (left side)
  3. Click on it to expand the view and see all .oplproject files in your workspace

The view automatically refreshes when you add, modify, or delete .oplproject files in your workspace.

Configuration

Set the path to your oplrun executable in VS Code settings:

  1. Open Settings (Ctrl+, or Cmd+,)
  2. Search for "OPL"
  3. Set OPL: Oplrun Path to your oplrun executable path

Default: oplrun (assumes it's in your system PATH)

Example paths:

  • Windows: C:\Program Files\IBM\ILOG\CPLEX_Studio221\opl\bin\x64_win64\oplrun.exe
  • Linux/Mac: /opt/ibm/ILOG/CPLEX_Studio221/opl/bin/x86-64_linux/oplrun

Alternatively, add this to your settings.json:

{
  "opl.oplrunPath": "C:\\Program Files\\IBM\\ILOG\\CPLEX_Studio221\\opl\\bin\\x64_win64\\oplrun.exe"
}

Example Files

Check the following folders for sample OPL files:

  • examples/ - Complete working examples:

    • cutstock.mod - Cutting stock optimization model
    • cutstock.dat - Data file for cutting stock model
  • examples/zoopl - Excellent example cases from https://github.com/AlexFleischerParis/zooopl - Thanks Alex !

Known Limitations

  • Semantic highlighting is not yet implemented (context-aware highlighting)
  • Some complex nested structures may not be perfectly highlighted
  • Execute blocks contain embedded code that uses basic highlighting
  • No IntelliSense or code completion yet
  • No error detection or diagnostics yet

Resources

  • IBM ILOG CPLEX Optimization Studio Documentation
  • OPL Language Reference

License

Apache License 2.0 - See LICENSE file for details

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