Hey guys -
I was thinking about a plugin that might be useful. It essentially offers a way to execute saved regular expressions on demand. For example, Iām often working with other peopleās code or HTML, and I find myself making the same set of changes over and over. One thing that Iām constantly doing is removing type=ātext/javascriptā and type=ātext/cssā from script and link tags, respectively (theyāre not necessary). If there was a plugin with a settings fileā¦
{
replacements: {
'Remove Link and Script Types': /\stype="text\/(?:css|javascript)/ig
}
}
I could then pull up the command palette, choose āRemove Link and Script Types,ā and the associated regular expression will instantly be run on the contents of the focused page.
ā¦Or maybe to remove all HTML comments from the page:
replacements: {
'Remove HTML Comments': /<!--\s\S]+?-->/g
}
It would be even neater if there was a way to stack these. So, in addition to single commands, I could also execute a series of them with a single command: first use this regular expression to remove comments, then make the first letter of all words in h1 tags capital, etc.
sequence: {
"Optimize HTML": [replacement1, replacement1, replacement1]
}
The regex references in the array would then be executed sequentially on the document.
Personally, Iād have a lot of uses for something like this, but Iām not sure if anyone else would. Let me know, and, if so, we may hire @weslly to make it.