Replace On Save
Run a search and replace before saving a file, it also supports REGEX for automation of content clean.
Extension Settings
Settings can be user or workspace settings.
To configure it only in the current workspace, edit the .vscode/settings.json
file relative to the root of the project and add the following settings:
"replace-on-save": {
"enabled": true / false,
"replacements": [
{
"languageIdentifiers": ["plaintext", "javascriptreact", ...],
"rules": [
{
"search": "Search Text / JavaScript regex",
"replace": "Replace Text"
},
{
...
}
]
},
{
...
}
]
}
To see a list of language identifiers go to the following link:
https://code.visualstudio.com/docs/languages/identifiers
Example Settings:
./.vscode/settings.json
"replace-on-save": {
"enabled": true,
"replacements": [
{
"languageIdentifiers": ["plaintext"],
"rules": [
{
"search": "dog", // This can be a valid javascript regular expression
"replace": "cat"
},
{
"search": "duck",
"replace": "chicken"
}
]
},
{
"languageIdentifiers": ["javascriptreact", "jsx"],
"rules": [
{
"search": "class=\"",
"replace": "className=\""
}
]
}
]
}
Release Notes
Search and replace works correctly.
1.0.0
Initial release of Replace On Save