Define rules to reduce opacity of repeating lines or blocks to be able to focus in main logic.
- Use simple regex rules to describe which part of the code will be dimmed.
- Use
rule
property to make the rule single-line (part of line that matches will be dimmed) - Use
start
andend
to make the rule multi-line (matching block of code will be dimmed) - Write per-workspace rules in
.vscode/config.json
underdim.rules
- Write per-language rules under file tags:
[js]
,[go]
,[json]
- 3 opacity tier: min, mid, max. Defaulted to 0.25, 0.50, 0.75 opacities.
{
"[go]": {
"dim.rules": [
{
"start": "if err != nil",
"end": "}"
}
]
}
}
Below code demonstrates, 2 per-language rule as well as one per-workspace rule.
- The rule defined for go is multi-line since it has
start
andend
properties. - The workspace-wide rule and the rule defined for json are single-line rules since they only have
rule
property. opacity
can be defined per-rule, if another tier then thedefaultOpacity
is desired.defaultScanLimit
is to limit dim to search only the firstn
lines of codefiles. Higher values can decrease the performance.maxLinesBetween
is to limit dim to search match for theend
onlyn
lines after the the text matches withstart
{
"[json]": {
"dim.rules": [
{
"rule": ".*\\$.*" // eg: $schema, $url
}
]
},
"[go]": {
"dim.rules": [
{
"start": "if err != nil",
"end": "}",
"opacity": "min",
"maxLinesBetween": 20
}
]
},
"dim.rules": [
{
"rule": "//.*", // comments
"opacity": "max"
}
],
"dim.defaultOpacityTier": "mid",
"dim.defaultScanLimit": 500,
"dim.defaultMaxLinesBetween": 5,
"dim.valueForMinTier": 0.2,
"dim.valueForMidTier": 0.3,
"dim.valueForMaxTier": 0.4
}
-
ignoreMatchingBraces
is under development - Option to leave the inner-area of
start
andend
matching texts without dimming:leaveBetween
- Context like usage with multiline rule property
subRules
- Dim rules might not be applied properly when working with TypeScript files. See issue details and leave feedback
- Issues and PRs => https://github.com/ufukty/dim
- See LICENSE file
- dim has inherited some code and logic from https://github.com/lorefnon/lowlight-patterns