Siemens SCL (Structured Control Language) support for Visual Studio Code.
Full highlighting for .scl files:
- Keywords - FUNCTION_BLOCK, IF/THEN, FOR/DO, CASE/OF, etc.
- Data types - Bool, Int, Real, Time, String, Array, Struct, IEC timers/counters
- Variables -
#localvariables,"DB_Name"references,%I/%Q/%Maddresses - Literals - Time (
T#5s), hex (16#FF00), binary (2#1010), dates (D#2024-01-15) - System functions - Type conversions, math, string functions, S7 system calls
- Comments -
//line and(* block *)comments - Pragmas -
{ S7_Optimized_Access := 'TRUE' }
Type a prefix and press Tab to insert:
| Prefix | Snippet |
|---|---|
fb |
Function Block (full template) |
fc |
Function with return type |
ob |
Organization Block |
db |
Data Block |
idb |
Instance Data Block |
udt |
User Defined Type (STRUCT) |
if |
IF THEN END_IF |
ife |
IF THEN ELSE END_IF |
ifei |
IF ELSIF ELSE END_IF |
for |
FOR loop |
while |
WHILE loop |
repeat |
REPEAT UNTIL loop |
case |
CASE OF statement |
var_input |
VAR_INPUT section |
var_output |
VAR_OUTPUT section |
var_inout |
VAR_IN_OUT section |
var_temp |
VAR_TEMP section |
ton |
TON timer call |
tof |
TOF timer call |
tp |
TP pulse timer call |
ctu |
CTU counter call |
rtrig |
R_TRIG rising edge |
ftrig |
F_TRIG falling edge |
call |
FB instance call |
norm |
NORM_X normalize |
scale |
SCALE_X scale |
motor |
Motor control pattern |
statemachine |
State machine (CASE) |
analogscale |
Analog scaling formula |
region |
REGION fold block |
Real-time autocomplete as you type:
- Keywords - All SCL block, variable and control flow keywords with documentation
- Data types - All S7 data types with size info (suggested automatically after
:) - System functions - Type conversions, math, string, scaling functions with parameter info
#variables - Type#to see all declared variables in the current block%addresses - Type%to get I/Q/M address suggestions"block references - Type"to see all block names in the file.member access - Timer/Counter outputs (Q, ET, CV) after dot
Hover over any keyword, data type or system function to see documentation.
Parameter hints when calling system functions - shows parameter names and types as you type.
Real-time error checking as you type:
Errors (red):
| Code | Check |
|---|---|
| SCL001 | Unmatched control flow (IF without END_IF, FOR without END_FOR, ...) |
| SCL002 | Unmatched VAR sections (VAR_INPUT without END_VAR) |
| SCL003 | Unmatched block declarations (FUNCTION_BLOCK without END_FUNCTION_BLOCK) |
| SCL004 | Duplicate variable names in same block |
| SCL005 | EXIT/CONTINUE outside of a loop |
Warnings (yellow):
| Code | Check |
|---|---|
| SCL101 | Unused variables (declared but never referenced) |
| SCL102 | Missing VERSION declaration |
| SCL103 | Missing S7_Optimized_Access pragma |
| SCL104 | CASE statement without ELSE branch |
| SCL105 | Empty BEGIN section (no code) |
Hints (grey):
| Code | Check |
|---|---|
| SCL201 | Naming convention (FB_, FC_, DB_ prefix suggestion) |
Full document outline in the Explorer panel and breadcrumb navigation:
- Blocks - FUNCTION_BLOCK, FUNCTION, ORGANIZATION_BLOCK, DATA_BLOCK, TYPE
- VAR sections - VAR_INPUT, VAR_OUTPUT, VAR_IN_OUT, VAR_TEMP, VAR as nested children
- Variables - All declared variables grouped under their section
- Correct SymbolKind mapping (FB=Class, FC=Function, OB=Event, DB=Struct)
Ctrl+Click or F12 to navigate:
#Variable- Jump to variable declaration in VAR section"BlockName"- Jump to block declaration (FUNCTION_BLOCK, FUNCTION, etc.)- Plain identifiers - Fallback match against all declared variables (case-insensitive)
Shift+Alt+F to format SCL code:
- Indentation - 4 spaces per nesting level, correct for all block/control structures
- Keyword casing - All SCL keywords converted to UPPERCASE
- Spacing - Consistent spacing around
:=,:,, - Preserves - Strings, comments, and pragmas are never modified
- CASE labels - Correct indentation for numeric case labels
Ctrl+. on linter warnings to auto-fix:
| Code | Quick Fix |
|---|---|
| SCL102 | Add VERSION : 0.1 declaration |
| SCL103 | Add { S7_Optimized_Access := 'TRUE' } pragma |
| SCL104 | Add ELSE branch to CASE statement |
| SCL201 | Rename block with FB_/FC_/DB_ prefix |
Automatic folding for:
- Block declarations (FUNCTION_BLOCK, FUNCTION, etc.)
- Variable sections (VAR_INPUT, VAR_OUTPUT, etc.)
- Control structures (IF, FOR, WHILE, CASE)
- Regions (REGION / END_REGION)
Automatic indent/outdent for block keywords and control flow.
Matching of parentheses, brackets, and (* *) comments.
Search for TIA-SCL in the Extensions view (Ctrl+Shift+X).
Download the .vsix from Releases, then:
code --install-extension tia-scl-0.4.0.vsixOr in VS Code: Ctrl+Shift+P → Extensions: Install from VSIX...
git clone https://github.com/kasi09/TIA-SCL.git
cd TIA-SCL
npm install && npm run build
# Copy to extensions folder (Windows):
cp -r . "%USERPROFILE%/.vscode/extensions/tia-scl"
# Restart VS CodeThe extension automatically associates with .scl files. To manually set the language mode, click the language indicator in the bottom right of VS Code and select SCL.
- TIA-Tools - Python toolkit for Siemens TIA Portal projects (reader, block generator, SCL generator, tag export)
MIT
