Giter Club home page Giter Club logo

highlight-regex's Introduction

Highlight regex

Highlight (decorate) what you want with Regex in VS Code

Examples at examples.md

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
    • Optionnal index property for indicate the index or name of match group of regex
    • Optionnal hoverMessage property for add a message or message lines of match group of regex at mouse hover
  • regexes: object list of regexes
    • Optionnal index property for indicate the index or name 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"
                                }
                            }
                        ]
                    }
                ]
            }
        ]
    }
]

highlight-regex's People

Contributors

mickaelblet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

doytsujin

highlight-regex's Issues

Decorations are not applied to the capture groups

Issue

When attempting to select capture groups for decoration, the decoration is not applied to the correct characters.

Example

Configuration

"highlight.regex.regexes": [
    {
      "languageIds": [
        "plaintext"
      ],
      "regexes": [
        {
          "regex": "match (ME) and (ME)",
          "decorations": [
            {
              "index": 1,
              "fontStyle": "italic",
            },
            {
              "index": 2,
              "fontWeight": "bold",
            }
          ]
        },
        {
          "regex": "and (THIS TOO)",
          "decorations": [
            {
              "index": 1,
              "fontWeight": "bold",
            },
          ]
        }
      ]
    },
  ],

Original File (test.txt)

match ME and ME and THIS TOO

Expected result

match _ME_ and **ME** and **THIS TOO**

Actual result

_ma_**tc**h ME and ME **and THIS** TOO

My Visual Studio Code Info

Version: 1.81.1 (user setup)
Commit: 6c3e3dba23e8fadc360aed75ce363ba185c49794
Date: 2023-08-09T22:22:42.175Z
Electron: 22.3.18
ElectronBuildId: 22689846
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Windows_NT x64 10.0.19045
Extensions: Tested in a profile with only Highlight - Regex installed.

Invalid regular expression in latest version of vscode

SyntaxError: Invalid regular expression: /(((?<=((?: +)?)(`{3}\w+\s)))((?:.|\s)*)(?)((?=(\s)((?: +)?)(`{3}))))/g: Invalid group
Version: 1.82.0-insider
Commit: 501baeb5e07b5a404f862d922bacb93771d91331
Date: 2023-08-18T05:34:41.801Z
Electron: 25.5.0
ElectronBuildId: 23084831
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Darwin arm64 21.6.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.