Highlight (decorate) what you want with Regex in VS Code
Examples available at examples.md
Highlight Regex: Choose by name(s) (highlight.regex.choose.names) command.
Choose from tree your regexes.
Edit key(s) within workspace json settings.
Change the order of regexes to adjust their priority.
Delete with contectual menu.
Navigate through regex matches in the active editor.
Name | Command | Description |
---|---|---|
Highlight Regex: Choose by name(s) | highlight.regex.choose.names | Activate/Desactivate specific regexes |
Highlight Regex: Toggle | highlight.regex.toggle | Activate/Desactivate all scopes regexes |
Highlight Regex: Global Toggle | highlight.regex.global.toggle | Activate/Desactivate all regexes of global scope |
Highlight Regex: Workspace Toggle | highlight.regex.workspace.toggle | Activate/Desactivate all regexes of workspace scope |
Name | Description | Default |
---|---|---|
highlight.regex.cacheLimit | Limit of cache | 1000 |
highlight.regex.defaultRegexLimit | Default limit of search regex | 50000 |
highlight.regex.defaultRegexFlag | Default regex flag | gm |
highlight.regex.delay | Delay to applicate decorations after update events (in milliseconds) | 200 |
The highlight.regex.regexes and highlight.regex.workspace.regexes properties take a list of objects.
The first object level can include the following properties:
Name | Description |
---|---|
name | A name of regexes |
description | A description of regexes |
active | Set to false for disable these regexes |
languageIds | A list of language IDs used to apply child decorations |
languageRegex | If languageIds not define, A regex pattern that, when matched with the language ID, applies child decorations |
filenameRegex | A regex pattern that, when matched with the file path, applies child decorations |
regexes | A list of objects with the Regexes child settings properties |
Name | Description |
---|---|
index | The index or name of the matched regex group (default is 0) |
regex | The regex pattern to be applied (string or strings list) |
regexFlag | The flag for the regex (default is highlight.regex.defaultRegexFlag) |
regexLimit | The limit on how many matches the regex can find (default is highlight.regex.defaultRegexLimit) |
decorations | A list of VS Code decorations - Optionnal index property to indicate the index or name of the matched regex group. - Optionnal hoverMessage property to add a message when hovering over a match group |
regexes | A list of child Regexes child settings |
"highlight.regex.regexes": [
{
"name": "TODO/CRITICAL",
"description": "Show todo and critical keyword on comment(s)",
"languageRegex": "\\b(c|cpp|go|java|javascript|php|rust|typescript)\\b",
"regexes": [
{
// regex to find all within comments
"regex": [
"(?:[\"][^]*?(?:(?<!\\\\)[\"]))", // not in string
"|",
"(",
"(?:/\\*[^]*?\\*/)",
"|",
"(?://[^]*?(?:(?<!\\\\)$))",
")"
],
"regexFlag": "gm",
"regexLimit": 25000,
"regexes": [
{
"index": 1, // 1 for take comments match
"regex": [
"\\b(?<todo>TODO)\\b",
"|",
"\\b(CRITICAL)\\b"
],
"regexFlag": "gmi",
"regexLimit": 25000,
"decorations": [
{
"index": "todo", // match regex named 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, // (CRITICAL)
"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"
}
}
]
}
]
}
]
}
]