{ "folders": [ { "path": ".." } ], "settings": { "regexrobin.rules": [ // "At" references, like @Clara and @Gary. { "languages": ["markdown"], "regex": "(?<=(.*))(@(\\w+))(?=(.*))", "regexFlags": { "multiline": true }, "editor": [{ "group": 2, "color": "#66D9EF" }], "tree": { "group": ["Mentions", "$3"], "label": "$1$2$4" } }, // Jira links, like "ISSUE-123" { "regex": "ISSUE-\\d+", "tree": { "group": "Jira links" }, "editor": [ { "link": "https://myorg.atlassian.net/browse/$0", "color": "#66D9EF", "hoverMessage": "Jira ticket **$0**" } ] }, // Turns a pasted github pull request URL into something more readable, // like https://github.com/dlevs/duration-fns/pull/20. { "regex": "(https://github.com/.+?/)(.*?)(/pull/)(\\d+)", "editor": [ { "color": "#66D9EF" }, // Rather than replace the entire match, just replace parts of it, so the // majority of what is shown _is_ the original string, so cursor position // is predictable when it expands upon click. { "group": 1, "inlineReplacement": "" }, { "group": 3, "inlineReplacement": "#" } ] }, // Highlight "NOTE" comments until the end of the line, and add them to the tree view. { "regex": "(NOTE):(.*)", "tree": { "group": "Notes", "label": "$2" }, "editor": [ { "color": "#AE81FF" }, { "group": 1, "fontWeight": "bold", "textDecoration": "underline" } ] }, // Color subsequent lines for "NOTE": comments.. { "regex": { "template": "multi-line-match", "replace": { "TEXT": "NOTE" } }, "editor": [{ "group": 2, "color": "#AE81FF" }] }, // Highlight "TODO" comments until the end of the line, and add them to the tree view. { "regex": "(TODO):(.*)", "tree": { "group": "TODOs", "label": "$2" }, "editor": [ { "color": "#F92672" }, { "group": 1, "fontWeight": "bold", "textDecoration": "underline" } ] }, // Color subsequent lines for "TODO": comments. { "regex": { "template": "multi-line-match", "replace": { "TEXT": "TODO" } }, "editor": [{ "group": 2, "color": "#F92672" }] }, // A bit of a hack to make the "*" and "//" comment characters gray again, // since the NOTE and TODO rules above overrode them. { "regex": "^ *(//|\\*/|\\*|#|-|\\d+\\.)[^#] *", "regexFlags": { "multiline": true }, "editor": [{ "group": 1, "color": "gray" }] }, // An example of shortening text, like TIP: This is long text but will be shortened. { "regex": "TIP: .{1,14}(.+)?", "editor": [ { "color": "#E6DB74", "hoverMessage": "$0" }, { "group": 1, "inlineReplacement": "..." } ] }, // An example of shortening text in such a way that leads to worse UX when // clicking on the replacement, like ((Short text ahoy!)) { "regex": "\\(\\((.{0,7}).*?\\)\\)", "editor": [ { "color": "#AE81FF", "borderRadius": "3px", // This variable replacement does not work because the VSCode API does not make // dynamic styles (which change extremely frequently) easy, suggesting it's probably // a bad idea; like creating a bunch of CSS classes that can change on every keystroke. "gutterIconPath": "${workspaceFolder}/assets/icon.png", "gutterIconSize": "contain", "inlineReplacement": { "contentText": "👀 $1", "color": "#FD971F" }, "hoverMessage": "This style of shortening is not recommended because it replaces the entirety of the text, so when you click on it, the cursor always jumps to the start or end of the line.\n\nIt's better to use `inlineReplacement` for the specific capture groups you want to hide." } ] }, // Highlighting of handlebars-style variables, like "{{foo}}" { "regex": "{{(\\w*?)}}", "regexFlags": { "ignoreCase": true }, "editor": [ { "color": "#E6DB74" }, { "group": 1, "color": "#66D9EF", "textDecoration": "underline" } ] }, // Markdown link, like [Google](https://google.com) { "regex": "(\\[.+?\\])(\\((.+?)\\))", "editor": [ { "hoverMessage": "Link to $3", "color": "#66D9EF" }, // A limitation here is that the link must be applied only to the first group, // since group 2 will already have a link provided, and they can't be nested - // the outer link will just not work. { "group": 1, "link": "$3" }, { "group": 2, "inlineReplacement": "" } ] }, // HTML class attributes, like "class="foo bar"" { "regex": "class=\"(.*?)\"", "editor": [ { "group": 1, "inlineReplacement": { "contentText": "•••", "color": "#666" } } ] } ], "regexrobin.templates": { // A regex that matches all text after a given word ("TEXT:"), wrapping onto the next line // (but not 2 consecutive lines), as long as the next line has the same comment style as // the matched line. // // It is intended for TODO-style comments, like: // TODO: Refactor this // // This regex is complex. It reminds me of the [stack overflow thread saying regex is not suitable for HTML parsing](https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454). // Similarly, this regex will never work perfectly without using a language-aware parser. // But it's good enough. "multi-line-match": { "regex": [ // ------------------- CAPTURE GROUP 1 - Comment type ------------------- // Capture the start of the line. It will be used later as a backreference. "(", [ // 1. A comment. Capture the whitespace before, and comment token used. "^ *(?://|\\*|#)", // 2. A markdown list item. "^ *(?:-|\\d\\.)" ], ")", // --------------------------- TEXT TO MATCH ---------------------------- // Match anything, up until the text is found on this line. ".*?TEXT:", // --------------------- CAPTURE GROUP 2 - Content ---------------------- // The main capture group, capturing the content after "TEXT:" // Capture all the content on this line... "(.*", // ...and continue capturing on the next line. "(?:\n", [ // 1. Match same comment style and pre-comment-token indentation as above. "\\1", // 2. Do not match if the first non-whitespace character is a new list item. "(?! *(?:-|\\d\\.))" ], // There _must_ be non-whitespace content, otherwise the match is over, and // that content cannot be another match, since that would need to be a _new_ // match. "(?:(?!TEXT| *$).)+", ")*", // New lines are optional (0 or more) ")" ], "regexFlags": { "multiline": true } } } } }