Skip to content

stevengeeky/symbol-masks

Repository files navigation

Symbol Masks

Mask symbols in your code with custom styles and replacement text.

Demo

Prerequisites

Windows

You will need to install Windows Build Tools before installing this extension for it to work properly.

Usage

Specify a pattern that will match a symbol to be masked in your settings.json file:

"symbolMasks.masks": [
  {
    "language": "plaintext",
    "patterns": [
        {
            "pattern": "(?<=\\b)lambda(?=\\b)",
            "replace": "value": "λ",
            "style": {
              "fontWeight": "bold"
            }
        }
    ]
  }
]

Mask Multiple Symbols At Once

For efficiency, you can also match many symbols at once and map each of them to an individual mask:

"symbolMasks.masks": [
  {
    "language": "plaintext",
    "patterns": [
        {
            "pattern": "(?<=\\b)(lambda|omega)(?=\\b)",
            "replace": {
              "lambda": {
                  "value": "λ",
                  "fontWeight": "bold"
              },
              "omega": {
                  "value": "ω"
              }
            }
        }
    ]
  }
]

Mask Based On TextMate Scope

Creating more intelligent masks is as simple as specifying a textmate scope the mask should look for. This can be done in both single and multiple masking mode:

"symbolMasks.masks": [
  {
    "language": "typescript",
    "patterns": [
      {
        "pattern": "!==|!=",
        "replace": {
          "!=": {
            "scope": "keyword.operator.comparison",
            "text": ""
          },
          "!==": {
              "scope": "keyword.operator.comparison",
              "text": ""
          }
        }
      }
    ]
  }
]

The result:

Scope Based Masking

Since the !== in the comment does not match the specified scope, it doesn't get masked.

To find find the scopes for a given symbol, simply run Ctrl+Shift+P and the command Developer: Inspect Editor Tokens and Scopes:

Inspect Tokens

About

vscode plugin to mask symbols with prettier text

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published