Link Patterns is a VS Code extension that automatically turns text into links based upon regex patterns.
This project is no longer actively maintained. Its spiritual successor is Regex Robin, which does everything this extension does, and more.
Multiple patterns can be defined in your VS Code settings. The following examples highlight common use cases.
{
"patternlinks.rules": [
{
"linkPattern": "ISSUE-\\d+",
"linkTarget": "https://myorg.atlassian.net/browse/$0"
// Example URL: https://myorg.atlassian.net/browse/ISSUE-299
},
{
"linkPattern": "(FOO|BAR)-(\\d+)",
"linkTarget": "https://example.com/$1/$2",
// Example URL: https://example.com/FOO/123
// Limit to specific languages
"languages": ["plaintext", "markdown"]
},
{
"linkPattern": "SKU([A-Z_]+)",
"linkTarget": "https://shop.com?search=$1&min-price=\\$1"
// Example URL: https://shop.com?search=PRODUCT_CODE&min-price=$1
// Here, `\` is being used as an escape character to prevent substitution
// of the second `$1`.
}
]
}
When two rules apply to the same text, the one defined last wins.
{
"patternlinks.rules": [
// Match links like repo-name#22 to the relevant pull request
{
"linkPattern": "([a-z_-]+)#(\\d+)",
"linkPatternFlags": "i", // Case insensitive
"linkTarget": "https://github.com/myorg/$1/pull/$2"
},
// Match links like special-case#22 to the relevant pull request,
// which is in a different github organisation, and has a long,
// inconvenient name.
{
"linkPattern": "special-case#(\\d+)",
"linkTarget": "https://github.com/someorg/really-long-inconvenient-name/pull/$1"
}
]
}
The text special-case#22
technically matches both of these rules, but the second one is the one that takes effect.
- Clone this repository
npm install
to install dependenciesnpm run watch
to start the compiler in watch mode- Open this folder in VS Code and start the debugger (
F5
).