Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>elektrobit Template Syntax HighlighterNew to Visual Studio Code? Get it now.
elektrobit Template Syntax Highlighter

elektrobit Template Syntax Highlighter

NeilBest

|
2 installs
| (0) | Free
Syntax highlighting plugin that supports special syntax for EB template files (template directives such as [!IF], [!LOOP], [!MACRO], etc.)
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

EB Template Syntax Highlighter

A Visual Studio Code extension that provides syntax highlighting for Elektrobit (EB) template files used in AUTOSAR code generation.

Features

This extension provides syntax highlighting for EB template syntax, including:

  • Template Directives: [!IF], [!ELSEIF], [!ELSE], [!ENDIF], [!LOOP], [!ENDLOOP], [!FOR], [!ENDFOR], [!MACRO], [!ENDMACRO], [!CALL], [!NOCODE], [!ENDNOCODE], [!CODE], [!ENDCODE], [!CR]
  • Function Calls:
    • Text functions: text:match(), text:contains(), text:uniq(), text:toupper()
    • Node functions: node:value(), node:exists(), node:ref(), node:refvalid(), node:refs()
    • Number functions: num:i(), num:inttohex()
    • Variable functions: var:defined(), var:name()
    • EC functions: ecu:get(), ecu:list()
    • Variant functions: variant:size()
    • Other functions: contains(), count()
  • Variables:
    • Variable definitions: [!VAR "variableName"=...], [!FOR "variableName"=...]
    • Variable references: $variableName
  • Nested function calls with full support
  • Comments inside template blocks:
    • Multi-line comments: [!/* ... */!]
    • Single-line comments: [!// ...
  • Template syntax in comments: Template code inside /* ... */ and // comments is also highlighted

Installation

Option 1: From Marketplace (Recommended)

  1. Open VS Code
  2. Go to Extensions (Ctrl+Shift+X)
  3. Search for "EB Template Syntax Highlighter"
  4. Click Install

Usage

Important: Manual Language Mode Switching

This extension does NOT automatically associate with .c, .h, or .m files to preserve the default C/C++ syntax highlighting. You must manually switch to EB Template language mode when needed.

Switching Language Mode

  1. Open your EB template file (.c, .h, or .m extension)
  2. Click on the language indicator in the bottom-right corner of VS Code (e.g., "C" or "C++")
  3. Select "EB Template" from the dropdown menu

Alternatively, use the Command Palette:

  1. Press Ctrl+Shift+P
  2. Type "Change Language Mode"
  3. Select "EB Template"

Switching Back to C/C++

To return to normal C/C++ highlighting:

  1. Click on the language indicator (now showing "EB Template")
  2. Select "C" or "C++"

Syntax Examples

Template Directives

[!IF "text:toupper(./SomeNode)"!]
    // Code when condition is true
[!ELSEIF "./AnotherNode = 'VALUE'"!]
    // Alternative condition
[!ELSE!]
    // Fallback code
[!ENDIF!]

Function Calls

[!FOR "x" = "0" TO "count(AdcConfigSet/AdcHwUnit/*/AdcGroup/*)-1"!]
    [!VAR "channelId"="num:i($x + 1)"!]
    Channel: [!"$channelId"!]
[!ENDFOR!]

Nested Functions

[!IF "text:contains(ecu:list('Crc.Protocols.SwapBitByte.List'), ./CrcProtocolInfo/CrcProtocolType)"!]
    // Condition with nested function call
[!ENDIF!]

MACRO Definitions

[!MACRO "CrcProtocol"!][!//
[!NOCODE!]
    [!VAR "MacCrcProtocol"="node:value(./CrcProtocolInfo/CrcProtocolType)"!]
[!ENDNOCODE!][!//
[!"$MacCrcProtocol"!][!//
[!ENDMACRO!]

Comments with Template Syntax

/* CRC[!IF "var:defined('postBuildVariant')"!]_[!"text:toupper($postBuildVariant)"!][!ENDIF!]_PBCFG_H */

// [!IF "text:toupper($var)"!]This template code is also highlighted[!ENDIF!]

[!/*****************************************************************************/!][!//
[!/* This is a multi-line comment block inside template */!][!//
[!/* Everything inside [!/* ... */!] is highlighted as a comment */!][!//
[!/*****************************************************************************/!]

Highlighting Scope

Inside [!] Template Blocks

All template syntax is fully highlighted:

  • Keywords (IF, ELSE, LOOP, MACRO, VAR, etc.)
  • Function names and namespaces
  • Variable definitions and references
  • Strings and numbers
  • Operators

Outside [!] Template Blocks

Only C-style comments are highlighted:

  • // single-line comments
  • /* */ multi-line comments

Note: All other code outside template blocks appears as plain text to avoid conflicts with C/C++ highlighting.

Syntax Coloring

The extension uses the following color scheme (based on your VS Code theme):

  • Keywords: Purple (e.g., IF, ELSE, LOOP, MACRO, VAR)
  • Function Names: Blue
  • Function Namespaces: Blue
  • Variable References: Red
  • Variable Definitions: Red
  • Strings: Green
  • Comments: Gray
  • Numbers: Orange/Yellow

Requirements

  • Visual Studio Code version 1.80.0 or higher

Supported File Types

While the extension can be used with any file type, it's designed for:

  • .c files (C source files)
  • .h files (C header files)
  • .m files (EB template files)

Troubleshooting

Syntax highlighting is not showing

  1. Verify you have switched to "EB Template" language mode
  2. Reload the window: Ctrl+Shift+P → "Developer: Reload Window"
  3. Check that your template code uses [!] delimiters

Template blocks are highlighted as plain text

  1. Ensure the template blocks use correct syntax: [! and !]
  2. Check for typos in template directives
  3. Try reloading the window

Conflicts with C/C++ extension

This extension is designed to avoid conflicts by requiring manual language switching. If you experience issues, ensure only one language mode is active at a time.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE.md for details

Changelog

Version 0.0.3

  • Added text:toupper() function support
  • Improved variable highlighting in VAR/FOR statements
  • Added template syntax highlighting inside comments
  • Fixed nested function call highlighting
  • Removed all syntax highlighting outside template blocks (except comments)

Version 0.0.2

  • Initial release with basic template directive highlighting
  • Support for function calls and variables

Author

NeilBest

Acknowledgments

Built for Elektrobit (EB) template files used in AUTOSAR code generation.

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