SCPI Text File Syntax Highlighting
Syntax highlighting for SCPI command scripts stored in .txt files, with extra support for simple scripting patterns used in automated VISA workflows.
Features
- Highlights common SCPI-style control words and script keywords.
- Highlights numeric values, including optional scientific notation and units (
hz, khz, mhz, ghz).
- Highlights placeholders like
{channel} and keeps placeholder highlighting inside single-quoted strings.
- Supports line comments with
//.
- Adds bracket pairing and auto-closing for
(), [], {}, and single quotes.
- Enables
Ctrl+/ line commenting when editing SCPI files.
File Association
This extension currently associates the scpi language mode with .txt files.
If you open a plain text file that contains SCPI commands, it should automatically receive SCPI highlighting.
Example
// Instrument connection
TCPIP 192.168.1.100
var channel
channel = 1
IF channel == 1 AND 1.0e3khz >= 100hz
MEAS:VOLT? {channel}
ENDIF
Supported Patterns
- Comments:
// ...
- Numbers: integers, decimals, scientific notation, optional frequency units
- Placeholders:
{name}
- Declarations:
var, vars
- Flow/control words:
FORLOOP, END, IF, ENDIF, WHILE, ENDW, BREAK, BREAKPOINT
- Operators/tokens:
==, !=, >=, <=, ,, AND, OR
Keyboard Shortcut
- Toggle line comment:
Ctrl+/ (when editorLangId == scpi)
Extension Settings
This extension does not currently contribute custom settings.
Release Notes
See CHANGELOG.md for version history and updates.
Development
Prerequisites
- Node.js 20+
- VS Code 1.96+
Install dependencies
npm install
Build
npm run compile
Watch mode
npm run watch
Lint
npm run lint
Test
npm test
Run in Extension Development Host
- Open this project in VS Code.
- Press
F5 to launch a new Extension Development Host window.
- Open a
.txt file with SCPI commands and verify highlighting.
Publishing
The extension is configured with publisher EliamCalvo and package name scpi-visa-text-extension.
Before publishing:
- Update version in package.json.
- Add notes to CHANGELOG.md.
- Package and publish using your preferred VS Code extension publishing workflow.
| |