sublime syntax for ident like Ident
- User
sublime syntax for ident like
Ident - Assistant
sublime syntax for ident like Ident
To create syntax highlighting for an identifier like Ident using Sublime Text's syntax definition system, you would need to define it in a .sublime-syntax file. Sublime Text syntax definitions use YAML syntax and allow you to define contexts and rules for highlighting text according to patterns.
Below is an example of how you might create a simple syntax highlighting definition for an identifier such as Ident:
Create a new .sublime-syntax file: You might name it CustomIdentHighlight.sublime-syntax.
Define the basic structure: Start with the primary fields (%YAML, name, file_extensions, and scope):
%YAML 1.2
---
# See http://www.sublimetext.com/docs/syntax.html for documentation
name: Custom Identifier Highlight
file_extensions:
- txt # Adjust the extension to the file types you want to apply this syntax to
scope: source.custom_ident
contexts:
main:
Ident: main:
- match: '\bIdent\b'
scope: keyword.custom.ident
push: expression
expression:
- match: '\b\w+\b'
scope: variable.other
- match: '$'
scope: punctuation.definition.string.end
pop: true
This example syntax definition has two contexts: main and expression. In the main context, it looks for the exact word Ident (using \b around the word to ensure it is a standalone word, not part of another string). When it finds it, it applies a custom scope called keyword.custom.ident, which you can style in your color scheme file, and then it transitions into the expression context.
The expression context is a simple placeholder here. It will scope any word as a variable and works until it encounters a line end ($), at which point it pops back to the main context.
To actually see the effect in your Sublime Text editor, you also need to define the color for keyword.custom.ident in your color scheme (.sublime-color-scheme file):
{
"name": "Your Color Scheme",
"variables": {},
"globals": {},
"rules": [
{
"scope": "keyword.custom.ident",
"foreground": "#FF0000", // Example: Red color for `Ident`
"font_style": "bold"
}
]
}
.sublime-syntax file in the User package directory (you can find this directory via "Preferences > Browse Packages" in Sublime Text)..txt file if that’s what you set) and select the syntax from the bottom-right of the Sublime window or from the Command Palette (Ctrl+Shift+P) by searching for "Set Syntax: Custom Identifier Highlight".Please adjust the details according to your needs, such as handling different combinations or adding more sophisticated word checks. This basic setup should be a good starting point for creating a custom identifier highlight in Sublime Text.
Not yet included in a published release.