Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Replace On SaveNew to Visual Studio Code? Get it now.
Replace On Save

Replace On Save

EduardoDevop

|
679 installs
| (1) | Free
Run a search and replace before saving a file, it also supports REGEX
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

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

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft