CRBasic Language Support Extension

This Visual Studio Code extension provides comprehensive language support for the CRBasic programming language, used for programming Campbell Scientific CR and GRANITE series data loggers. Features include syntax highlighting, IntelliSense, signature help, hover documentation, code navigation, diagnostics, quick fixes, and an instruction browser panel.
Supported Dataloggers
This extension provides model-specific support for the following Campbell Scientific dataloggers:
| Datalogger |
Series |
Description |
| CR1000X / CR1000Xe |
CR Series |
Measurement and control datalogger with analog and digital I/O |
| CR6 |
CR Series |
Measurement and control datalogger with universal terminals |
| CR300 |
CR Series |
Compact measurement and control datalogger |
| CR310 |
CR Series |
CR300 with Wi-Fi and Ethernet communications |
| CR350 |
CR Series |
Compact datalogger with extended measurement capabilities |
| GRANITE6 |
GRANITE Series |
High-performance measurement and control data acquisition system |
| GRANITE9 |
GRANITE Series |
High-performance data acquisition system without native measurement |
| GRANITE10 |
GRANITE Series |
High-performance data acquisition system without native measurement |
IntelliSense, hover documentation, the Instruction Panel, and documentation links are all filtered based on the selected datalogger model, so you only see what your hardware supports.
Installation
From the VS Code Marketplace
- Open VS Code
- Go to the Extensions view (
Ctrl+Shift+X / Cmd+Shift+X)
- Search for "CRBasic"
- Click Install on CRBasic VSCode Support - Campbell Scientific, Inc.
From a VSIX File
- Download the
.vsix file
- In VS Code, open the Command Palette (
Ctrl+Shift+P / Cmd+Shift+P)
- Run Extensions: Install from VSIX...
- Select the downloaded
.vsix file
Getting Started
- Open or create a CRBasic file with any supported extension:
.crb, .cr1x, .cr300, .cr6, .dld
- Select your datalogger model via
File > Preferences > Settings and search for crbasic.dataloggerModel (or let the extension auto-detect it from the first line of your file)
- Start typing to see IntelliSense suggestions, or browse the Instruction Panel in the Activity Bar sidebar
- Create a new program from a template via
File > New File... > CRBasic Program
Features
Syntax Highlighting
Comprehensive syntax highlighting for all CRBasic keywords, instructions, operators, data types, and comments. Semantic highlighting provides distinct colors for public variables, private variables, constants, data tables, and functions based on their declarations.
IntelliSense & Code Completion
- Smart auto-completion for 500+ CRBasic instructions and keywords
- Model-specific filtering -- only instructions supported by your configured datalogger model are shown
- Context-aware suggestions (e.g., output processing instructions only appear inside DataTable blocks)
- Categorized completions with detailed documentation
- Snippet support with tab stops for quick code entry
Signature Help
Inline parameter hints for all CRBasic functions showing:
- Function signature with all parameters
- Parameter descriptions
- Current parameter highlighting as you type
Hover Documentation
Hover over any CRBasic keyword or function to see:
- Function signature
- Detailed parameter information
- Links to official Campbell Scientific documentation (model-specific)
Documentation links dynamically point to the correct datalogger's help site based on your configured model.
Code Navigation
| Action |
Shortcut |
Description |
| Go to Definition |
F12 |
Jump to variable, constant, table, or subroutine declarations |
| Find All References |
Shift+F12 |
Find all usages of variables, tables, and subroutines |
| Rename Symbol |
F2 |
Rename a variable, constant, data table, subroutine, or function across the entire file |
| Include File Navigation |
Ctrl+Click |
Click on Include "filename" paths to open the included file |
| Breadcrumbs |
Breadcrumb bar |
Shows current scope path (e.g., BeginProg > Scan) as you navigate |
| CodeLens |
Above declarations |
Shows reference counts (e.g., "3 references") above each variable, constant, table, and subroutine |
| Document Outline |
CRBasic sidebar |
View all variables, constants, data tables, and subroutines |
Code Diagnostics
Real-time validation that checks for:
- Mismatched Begin/End pairs (BeginProg/EndProg, If/EndIf, For/Next, etc.)
- Mismatched preprocessor directives (#If/#EndIf)
- Unclosed code blocks
- Unexpected end statements
- Unused variables, constants, data tables, subroutines, and functions (shown as faded text)
- Duplicate variable, constant, data table, and subroutine declarations
- Incorrect argument counts in built-in function calls (too many or too few arguments)
- Literal type mismatches in function arguments (e.g., string literal where numeric expected, literal value where variable reference required)
Quick Fixes
Automatic code actions to fix common issues:
- Add missing
EndIf for If statements
- Add missing
EndTable for DataTable blocks
- Add missing
Next for For loops
- Add missing
EndSub for subroutines
- Add missing
#EndIf for preprocessor conditionals
Auto-Capitalize Keywords & Variable Name Matching
Automatically corrects the casing of CRBasic identifiers as you type:
- Keywords & instructions — all 500+ built-in instructions are corrected to their canonical PascalCase (e.g.,
beginprog → BeginProg, scan → Scan)
- Logical operators —
and → AND, or → OR, not → NOT, xor → XOR, mod → MOD, imp → IMP, intdv → INTDV
- Data types —
float → Float, long → Long, double → Double, boolean → Boolean, string → String
- Other keywords —
as → As, true → True, false → False, nan → NAN
- Variable name matching — corrects variable, constant, data table, and subroutine names to match their original declaration casing
- Skips corrections inside string literals and comments
- Configurable via
crbasic.enableAutoCaseCorrection
Format your entire CRBasic program with proper indentation using Format Document (Shift+Alt+F). The formatter:
- Automatically indents all block structures (BeginProg, Scan, If/Else/EndIf, For/Next, Sub/EndSub, DataTable, Select Case, While/Wend, Do/Loop, and more)
- Handles preprocessor blocks (
#If/#ElseIf/#Else/#EndIf)
- Correctly identifies single-line
If x Then y statements (no false indentation)
- Corrects keyword and variable name casing (when
crbasic.enableAutoCaseCorrection is enabled)
- Respects your editor's tab size and spaces/tabs preference
- Strips trailing whitespace while preserving blank lines
- Ignores keywords inside string literals
Compile Program (Windows Only)
Compile your CRBasic program using Campbell Scientific's official compiler directly from VS Code:
- Click the play button in the editor title bar, right-click and select CRBasic: Compile Program, use the Command Palette, or press
Ctrl+F6
- The correct compiler is auto-selected based on the detected datalogger model
- Compiler errors and warnings appear as VS Code diagnostics with correct line numbers
- Full compiler output is shown in the CRBasic Compiler output channel
- The file is automatically saved before compiling
- Requires the Campbell Scientific compilers to be installed (included with LoggerNet or the standalone CRBasic Editor)
- Configure the compiler directory via
crbasic.compilerDirectory if installed to a non-default location
Code Folding
Collapse and expand code blocks including:
Scan / NextScan loops
DataTable / EndTable blocks
If / Then / EndIf conditionals
For / Next loops
Sub / EndSub subroutines
SlowSequence / EndSequence blocks
Document Outline Panel
A color-coded tree view in the CRBasic sidebar that displays all symbols in your program at a glance:
- Variables (blue) — Public variable declarations
- Dim Variables (gray) — Private/Dim variable declarations, shown with a distinct field icon
- Constants (orange) — Const declarations
- Data Tables (teal) — DataTable blocks
- Subroutines (purple) — Sub declarations
- Click any symbol to navigate to its location in the file
- Automatically refreshes as you edit
- Symbol colors are customizable via
workbench.colorCustomizations (see Configuration)
Instruction Panel
A dedicated sidebar panel for browsing all CRBasic instructions, accessible via the CRBasic icon in the Activity Bar:
- Alphabetical list of 500+ instructions with category labels
- Search functionality to filter instructions by name
- Category filter to show only specific instruction types (Measurement, Math, Data Tables, etc.)
- Filtered by datalogger model -- only shows instructions supported by the configured logger
- Click the + button to insert an instruction at the cursor position (with snippet tab stops)
- Click the ? button to open the Campbell Scientific documentation for that instruction
- The panel only appears when editing CRBasic files
New Program Template
Quickly scaffold a new CRBasic program:
- Use File > New File... > CRBasic Program or the Command Palette (
CRBasic: New Program)
- Prompts for the target datalogger model
- Inserts a standard program template with the correct first-line datalogger declaration
Auto-Detect Datalogger Model
The extension reads the first line of CRBasic files (e.g., 'CR1000X Series Datalogger) to automatically detect the target model, overriding the global setting on a per-file basis. This means each file can target a different datalogger without changing settings.
Configuration
This extension provides the following settings (accessible via File > Preferences > Settings):
| Setting |
Default |
Description |
crbasic.dataloggerModel |
CR1000X |
Select your Campbell Scientific data logger model. Controls which instructions appear in completions, hover help, the Instruction Panel, and documentation links. Options: CR1000X, CR6, CR300, CR310, CR350, GRANITE6, GRANITE9, GRANITE10 |
crbasic.enableDiagnostics |
true |
Enable or disable real-time syntax validation and diagnostics |
crbasic.enableCodeActions |
true |
Enable or disable quick fix suggestions for common errors |
crbasic.enableUnusedVariableDetection |
true |
Enable or disable detection of declared but unused variables, constants, data tables, and subroutines |
crbasic.enableDuplicateDeclarationDetection |
true |
Enable or disable detection of duplicate variable, constant, data table, and subroutine declarations |
crbasic.enableCodeLens |
true |
Show or hide reference counts above declarations |
crbasic.enableSemanticHighlighting |
true |
Enable or disable semantic highlighting for distinct variable/constant/table/function colors |
crbasic.enableArgumentCountValidation |
true |
Enable or disable detection of incorrect argument counts in built-in function calls |
crbasic.enableArgumentTypeValidation |
true |
Enable or disable detection of literal type mismatches in built-in function call arguments |
crbasic.enableFormatting |
true |
Enable or disable the built-in document formatter (Format Document / Shift+Alt+F) |
crbasic.enableAutoCaseCorrection |
true |
Automatically correct the casing of keywords, instructions, operators, and declared variable names as you type and during Format Document |
crbasic.compilerDirectory |
C:\Campbellsci\Lib\Compilers |
Path to the directory containing Campbell Scientific compiler executables. Installed with LoggerNet or the standalone CRBasic Editor. (Windows only) |
Document Outline Colors
Customize symbol colors in the Document Outline panel via workbench.colorCustomizations in your VS Code settings:
| Color ID |
Default (Dark) |
Description |
crbasic.symbolVariable |
#75BEFF |
Public variable symbols |
crbasic.symbolDimVariable |
#9E9E9E |
Dim (private) variable symbols |
crbasic.symbolConstant |
#EE9D28 |
Constant symbols |
crbasic.symbolDataTable |
#4EC9B0 |
Data Table symbols |
crbasic.symbolSubroutine |
#B180D7 |
Subroutine symbols |
Keyboard Shortcuts
| Shortcut |
Action |
Ctrl+Space / Cmd+Space |
Trigger IntelliSense suggestions |
Ctrl+Shift+Space / Cmd+Shift+Space |
Trigger signature help |
F12 |
Go to Definition |
Shift+F12 |
Find All References |
Shift+Alt+F |
Format Document (reformat indentation) |
Ctrl+F6 |
Compile Program (Windows only) |
Ctrl+Shift+O / Cmd+Shift+O |
Go to Symbol (document outline) |
Ctrl+Shift+P / Cmd+Shift+P |
Command Palette (search for "CRBasic" commands) |
Online CRBasic Help
CRBasic help for each specific Campbell Scientific data logger can be found at:
Supported File Extensions
.crb, .cr1x, .cr300, .cr6, .dld
Known Issues
- IntelliSense help text is not yet complete for all CRBasic instructions. Coverage is expanding with each release.
- Not all of the latest datalogger instructions are included yet (but coverage is growing -- 500+ instructions and counting).
- Block validation (If/EndIf, For/Next) is automatically skipped in files containing preprocessor conditionals (
#If) since conditional compilation makes block matching unreliable.
Requirements
VS Code 1.100.0 or later.
Current Maintainers
| |