SPICE syntax highlighting reference leoheck/sublime-spice TextMate rules.
Other useful rules reference see: 1995parham/vim-spice
Snippets reference: bzisjo/vscode-spice-support
Maintained by Xuan Li, Wiener Technology, Beijing.
Seeing SPICE in VSCode Marketplace
- CHANGELOG.md — release history
- docs/SYNTAX.md — SPICE/HSPICE vs Spectre dialect comparison & navigation matrix
- docs/ARCHITECTURE.md — navigation engine design (
.libdual syntax,.param/section scope, Spectre support) - docs/RELEASE.md — build, package, and publish guide
- docs/TODO.md — known limitations and backlog
Folding is supported for the following block structures:
.subckt/.ends.lib/.endl— only the section definition form.lib NAME….endl NAMEstarts a fold; the file reference form.lib 'file' NAMEdoes not start a fold block..control/.endc.if/.endif.data/.enddata.modelblocks (parameter list opened by(and closed by)).statistics/.endstatistics.section/.endsection- Spectre:
subckt/ends,if/endif,statistics,process,section/endsection
.param / .options are single statements (parameters may use + continuation) and are not treated as fold blocks.
These are all VS Code default shortcuts (no configuration needed) and work well for process-library files that contain many .lib / .model blocks:
| Action | Windows / Linux | macOS | Notes |
|---|---|---|---|
| Fold innermost block at cursor | Ctrl+Shift+[ |
⌥⌘[ |
Press repeatedly to fold outward layer by layer (.model first, then the enclosing .lib, …) |
| Unfold block at cursor | Ctrl+Shift+] |
⌥⌘] |
Press repeatedly to unfold inward |
| Recursively fold block + children | Ctrl+K Ctrl+[ |
⌘K ⌘[ |
Folds the current block and everything nested inside |
| Recursively unfold | Ctrl+K Ctrl+] |
⌘K ⌘] |
|
| Toggle fold at cursor | Ctrl+K Ctrl+L |
⌘K ⌘L |
|
| Fold by level | Ctrl+K Ctrl+1…7 |
⌘K ⌘1…7 |
1 = only outermost (e.g. all .lib), 2 = also .model, … |
| Fold all | Ctrl+K Ctrl+0 |
⌘K ⌘0 |
|
| Unfold all | Ctrl+K Ctrl+J |
⌘K ⌘J |
Recommended workflow for browsing a process library: press Ctrl+K Ctrl+1 to collapse every top-level .lib section to a single line so you can survey all corners at a glance; expand the corner you need, then use Ctrl+Shift+[ to drill down layer by layer.
To view or customize all folding shortcuts: open the Command Palette (
Ctrl+Shift+P) and typefold.
- Comments:
*,//,;,$ - Hierarchical Blocks:
.subckt/.ends,.lib/.endl,.control/.endc,.if/.endif - Simulation Commands:
.ac,.dc,.tran,.op,.noise,.tf,.disto,.four - Configuration Commands:
.include,.model,.param,.global,.options,.temp,.step,.func - Measurement Commands:
.meas/.measure - Output Commands:
.save,.print,.plot,.probe - Circuit Elements:
- Passive:
R(Resistor),C(Capacitor),L(Inductor),K(Coupling) - Active:
D(Diode),Q(BJT),J(JFET),M(MOSFET),Z(MESFET) - Sources:
V(Voltage),I(Current),B(Behavioral),E(VCVS),F(CCCS),G(VCCS),H(CCVS) - Other:
T(Transmission Line),S/W(Switch),X(Subcircuit Instance)
- Passive:
- Functions: Math functions (
abs,sin,cos,log, etc.) and source functions (pulse,pwl,sin,exp) - Numbers:
- Scientific notation (e.g.,
1.5e+09,2.3E-12) — the exponent is colored distinctly - Engineering notation (e.g.,
1k,100n,2.2u) — the scale suffix is colored distinctly
- Scientific notation (e.g.,
- Operators: Comparison and logical operators
- Keywords: Sweep parameters (
SWEEP,START,STOP,STEP), analysis types (dec,oct,lin)
- Keywords:
parameters,simulator,analysis,design,model,instance,global,include,info,save,plot,print,assert,alter,statistics,process,section,connect,options,temp,lib,if/else/endif,end - Analysis Types:
ac,dc,tran,noise,stb,pss,pac,pnoise,xf,dcmatch,acmatch,sens - Devices:
resistor,capacitor,inductor,diode,bipolar,mosfet,jfet,vsource,isource,vcvs,vccs,ccvs,cccs,tline,switch - Blocks:
subckt/ends,if/endif,statistics,process,section/endsection
.sub- Subcircuit definition.lib- Library declaration.con- Control block.if/.ifelse/.elseif- Conditional statements.inc- Include file.mod- Model definition.glob- Global node.opt- Options.temp- Temperature.func- Function definition.data- Data block.end- End of netlist
.ac- AC analysis (basic, sweep, data-driven).dc- DC analysis (basic, sweep, data-driven).tran- Transient analysis (basic, with start, sweep, data-driven).op- Operating point.noise- Noise analysis.tf- Transfer function.four- Fourier analysis.disto- Distortion analysis.step- Parameter sweep.node- Nodeset
.meas- Measure rise/fall/delay.measwhen- Measure when condition.measfind- Measure find at value.measavg- Measure average.measrms- Measure RMS.measpp- Measure peak-to-peak.measmin- Measure minimum.measmax- Measure maximum
.save- Save signal.print- Print output.plot- Plot output.probe- Probe output
R- ResistorC- CapacitorL- InductorD- DiodeQ- BJT TransistorM- MOSFETJ- JFETX- Subcircuit instanceVdc/Vac- Voltage source (DC/AC)Idc- Current source DCVpulse/Vsin- Pulse/Sinusoidal voltage sourceT- Transmission lineS- SwitchE/F/G/H- Controlled sources
pulse- Pulse waveformsin- Sinusoidal waveformexp- Exponential waveformpwl- Piece-wise linearsffm- Single FMam- AM modulated
tranfull- Complete transient analysis templateacfull- Complete AC analysis templatedcfull- Complete DC analysis template
subckt- Subcircuit definitionparameters- Parameter definitionsimulator- Simulator languageinclude- Include fileglobal- Global nodesave- Save signaloptions- Simulation optionsinfo- Informationdesign- Design specificationmodel- Model definitionassert- Assertionstatistics- Statistics blockprocess- Process blocksection/endsection- Section blockif/ifelse/endif- Conditional statementsend- End of netlist
ac- AC analysisdc- DC analysistran- Transient analysisnoise- Noise analysisstb- Stability analysispss- Periodic steady statepac- Periodic ACpnoise- Periodic noise
resistor- Resistorcapacitor- Capacitorinductor- Inductordiode- Diodemosfet- MOSFETbipolar- BJTjfet- JFETvsource- Voltage sourceisource- Current sourcevcvs/vccs/ccvs/cccs- Controlled sourcestline- Transmission lineswitch- Switch
- Comment Toggle: Use
Ctrl+/to toggle comments - Bracket Matching: Automatic bracket matching for
.subckt/.ends,.lib/.endl, etc. - Auto Closing: Automatic closing of brackets, parentheses, and quotes
- Indentation: Smart indentation for hierarchical blocks
- Code Folding: Fold/unfold block structures
IDE-style navigation across HSPICE and Spectre netlists, including process libraries (PDKs) linked via .INCLUDE / .INC / .LIB (HSPICE) or include / section (Spectre). The navigation engine runs entirely in-process — no language-server dependency. See docs/SYNTAX.md for what each dialect supports.
Navigation works in both dialects in any
.sp/.scs/.libfile. The examples below use HSPICE dot-command syntax; the Spectre equivalents (baresubckt/model/parameters/include/section) work the same way.
- From an
Xinstance name → its.SUBCKTdefinition. - From a
M/Q/Ddevice model name → its.MODELdefinition. - From a node on an
Xinstance → the matching port in the.SUBCKTheader. - From a variable reference inside an expression (e.g.
dLinlmin = 'L0-(dL+dmis)') → its.paramdefinition. - From a section name in
.lib 'file' section→ the corresponding.LIB section … .ENDLdefinition. - Works across files via
.INCLUDE/.INC/.LIBchains — included files do not need to be open.
When the same name is defined in multiple places (e.g. a model/param defined in several .LIB section corners), VS Code's native Peek picker lists all definitions to choose from.
- Over a subcircuit name → its port list.
- Over a model name → its type (e.g.
nmos,pnp). - Over a node on an
Xinstance → the matching port name; over a node on a device → the terminal name (drain/gate/source/ …). - Over a
.paramvariable → its value(s) (all definitions when multiple corners exist). - Over an environment variable (
$VAR/${VAR}) inside an.INCLUDEpath → its resolved value.
- All
Xinstances referencing a subcircuit, or all device instances referencing a model. - All expression sites referencing a
.paramvariable (inside other params and model cards).
The Outline panel lists every .SUBCKT, .MODEL, and .param, nested under their containing .LIB section, with click-to-navigate.
File paths in .INCLUDE / .INC and .lib 'file' section statements are Ctrl+Click links that open the target file; environment variables in paths are resolved.
HSPICE .lib 'file' section selects which definitions inside file are active. The extension resolves the active scope automatically when possible, and lets you pin it manually otherwise:
- Automatic (determined scope) — if the current file is included by an upstream netlist via
.lib 'thisFile' section, that section is used; F12 jumps straight to the in-scope definition with no ambiguity. - Manual (ambiguous scope) — when a file is opened directly (e.g. a shared PDK that many top-level netlists could include), run
SPICE: Select Active .LIB Sectionfrom the Command Palette or editor context menu to pin a section for the session;SPICE: Clear Manual Section Scoperesets it. When no scope is pinned and the scope is ambiguous, F12 returns all definitions so you can pick.
Scope resolution is structural (which
.LIB sectiona definition lives in), not a full HSPICE corner-value evaluation — it does not compute the numerically effective parameter values of a simulator run.
Warnings (yellow squiggle) for:
- Unknown subcircuit — an
Xinstance references a name not found in the file or its include graph. - Port-count mismatch — an
Xinstance provides a different number of nodes than its.SUBCKTdeclares ports.
- Case-insensitive symbol lookup (HSPICE semantics); original case is preserved for display.
- HSPICE
+line continuation and$/;inline comments are handled during parsing. .paramvariable references inside expressions are extracted by scanning identifiers and excluding function calls (name() and HSPICE built-in functions (max,pwr,agauss,v,i, …). This is best-effort and may produce false positives/negatives; it affects only reference completeness, never jump correctness.- Nested
.SUBCKTdefinitions are not supported (not valid HSPICE syntax). - The navigation engine is derived from HSPICE IntelliSense (MIT) and substantially extended; see
LICENSE(Third-Party Notice) andsrc/file headers.
.ckt, .sp, .net, .cir, .scs, .mod, .mdl, .lib, .sub, .l (HSPICE process library), .lis (SPICE output listing), .dspf (DSPF parasitic netlist)
- Refine DSPF parasitic R/C grouping highlight
- More snippet coverage
-
.paramvariable references from inside X-instance / device parameter expressions (currently resolved only from.paramvalues and model-card'...'strings) - Spectre (
.scs) navigation — added in 0.3.5 (Go-to-Definition / Hover / References / Outline /includelinks /sectionscope)
- Fork it ( https://github.com/lxTHU/vscode-spice )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
See CHANGELOG.md for the full history. Recent highlights:
- [0.3.5] Spectre (
.scs) navigation: Go-to-Definition / Hover / References / Outline /includelinks /sectionscope now work on Spectre model libraries too, including mixed-dialect files. New docs/SYNTAX.md compares the two dialect families. - [0.3.1] Fix
.libdual-syntax (definition vs file reference) — the root cause of navigation failure on large PDK files. Add.paramvariable navigation,.LIB sectionnavigation, section-scope resolution (auto + manual), and hierarchical Outline. - [0.3.0] Add IDE-style netlist navigation: Go to Definition, Hover, Find References, Outline, Diagnostics, and
.INCLUDEfile links. Runs in-process (no language server). - [0.2.4] Fix
.lib/.modelfolding semantics; add.lextension. - [0.2.3] Fix
.modelfolding; add.enddatahighlight,.lis/.dspfextensions, Spectre snippets. - [0.2.1] Fix code folding for all block structures; improve scientific/engineering notation highlighting.
- [0.1.0] Add basic snippets support (ref bzisjo's great work).
- [0.0.6] Fix toggle-comment bug (
Ctrl+/adds*comment toggle).
MIT — Copyright (c) 2022-2026 Xuan Li, Wiener Technology, Beijing. See LICENSE.