Highlight regex

Highlight (decorate) what you want with Regex in VS Code
Regexes Settings
The regexes property is a object list.
The first objects can take a string list (languageIds) and object list (regexes).
regexes object properties:
- regex: string of regex
- regexFlag: flag of regex (default "gm")
- regexLimit: limit search of the regex property (default 50000)
- decorations: list of VS Code decoration (with optionnal index property for indicate the index of match group of regex)
- regexes: object list of regexes (with optionnal index property for indicate the index of match group of regex)
Default Regexes Setting
"highlight.regex.regexes": [
{
"languageIds": [ "c", "cpp", "go", "java", "javascript", "php", "rust", "typescript" ],
"regexes": [
{
// regex to find all within comments
"regex": "(/\\*[^]*?\\*/)|(//[^]*?(?:(?<!\\\\)$))",
"regexFlag": "gm",
"regexLimit": 25000,
"regexes": [
{
"index": 0, // 0 for take all regex match (this is optionnal)
"regex": "\\b(TODO)\\b|\\b(TADA)\\b",
"regexFlag": "gmi",
"regexLimit": 25000,
"decorations": [
{
"index": 1, // index match regex group (TODO)
"borderRadius": "4px",
"fontWeight": "bold",
"overviewRulerColor": "#FF9900FF",
"overviewRulerLane": 4,
"light": {
"color": "#000000",
"backgroundColor": "#FF990050",
"border": "1px solid #FF990090"
},
"dark": {
"color": "#FFFFFF",
"backgroundColor": "#FF990090",
"border": "1px solid #FF990050"
}
},
{
"index": 2, // (TADA)
"borderRadius": "4px",
"fontWeight": "bold",
"overviewRulerColor": "#FF0000FF",
"overviewRulerLane": 4,
"light": {
"color": "#000000",
"backgroundColor": "#FF000050",
"border": "1px solid #FF000090"
},
"dark": {
"color": "#FFFFFF",
"backgroundColor": "#FF990090",
"border": "1px solid #FF990050"
}
}
]
}
]
}
]
}
]
Examples
- highlight member variables in cpp and keyword this
"highlight-regex.regexes": [
{
"languageIds": [ "c", "cpp" ],
"regexes": [
{
"regex": "(?:['][^]*?(?:(?<!(?<!\\\\)\\\\)['])|[\"][^]*?(?:(?<!\\\\)[\"])|\\/\\*[^]*?\\*\\/|//[^]*?(?:(?<!\\\\)$)|#[^]*?(?:(?<!\\\\)$))|(\\b(?!__)_\\w+\\b)|(\\bthis\\b)", // not in string or comment or define
"regexFlag": "gm",
"regexLimit": 10000,
"decorations": [
{
"index": 1, // _\w+
"fontWeight": "bold; text-shadow: 0px 0px 10px",
"fontStyle": "italic"
},
{
"index": 2, // this
"fontWeight": "bold",
"fontStyle": "italic"
}
]
}
]
}
]
{
"languageIds": [ "python" ],
"regexes": [
{
"regex": "(\"\"\"[^]*?\"\"\")|(#[^]*?(?:(?<!\\\\)$))",
"regexFlag": "gm",
"regexes": [
{
"index": 0,
"regex": "(\\bTODO\\b)|(\\bTADA\\b)",
"regexFlag": "gmi",
"decorations": [
{
"index": 1,
"borderRadius": "4px",
"fontWeight": "bold",
"overviewRulerColor": "#FF9900FF",
"overviewRulerLane": 4,
"light": {
"color": "#000000",
"backgroundColor": "#FF990050",
"border": "1px solid #FF990090",
},
"dark": {
"color": "#FFFFFF",
"backgroundColor": "#FF990090",
"border": "1px solid #FF990050",
}
},
{
"index": 2,
"borderRadius": "4px",
"fontWeight": "bold",
"overviewRulerColor": "#FF0000FF",
"overviewRulerLane": 4,
"light": {
"color": "#000000",
"backgroundColor": "#FF000050",
"border": "1px solid #FF000090",
},
"dark": {
"color": "#FFFFFF",
"backgroundColor": "#FF000090",
"border": "1px solid #FF000050",
}
}
]
}
]
}
]
}