Replace Commands

approved

by Eric Lowry

This plugin has not been manually reviewed by Obsidian staff. Preconfigure custom search and replace actions using plain text or regex to quickly modify selections or documents.

1 stars104 downloadsUpdated 10d ago0BSD

Replace Commands

License: 0-BSD Latest GitHub release

An Obsidian plugin that lets you preconfigure custom search and replace actions using plain text or regex to quickly modify selections or documents.

Whether you need to quickly clean up messy OCR text, standardize markdown formatting, or chain complex regex replacements, this plugin lets you save those sequences as single-click actions.

Features

  • Custom Actions: Create named actions (e.g., "Clean OCR", "Format Tables") that contain one or more search/replace rules.
  • Live Preview Test Bench: Instantly test your rules in settings using a real-time preview. Each rule shows its step-by-step intermediate output before giving the final result.
  • Sequential Processing & Reordering: Chain multiple rules perfectly and easily rearrange their execution order directly in the UI.
  • Smart Targeting: If you highlight text, the action only applies to your selection. If nothing is selected, it applies to the entire document.
  • Single-Step Undo: No matter how many rules are in your action, they are applied as a single atomic transaction. One press of Ctrl+Z undoes the entire operation.
  • Regex & Capture Groups: Full support for JavaScript Regular Expressions. Use capture groups (e.g., $1, $2) in your replacement strings.
  • Custom Regex Flags: Easily add flags like i (case-insensitive) or m (multiline) to your regex rules.
  • Plaintext Escapes: If you turn regex off, you can still search for \n (newlines) and \t (tabs) in plaintext mode.
  • Easy Access: Run your actions directly from the Obsidian Command Palette (Ctrl/Cmd + P), or add them to the right-click Editor Context Menu.

How to Use

  1. Configure an Action: - Go to Settings -> Replace Commands.
    • Click Add new action and give it a name (Example: "Fix spacing").
    • Add your search and replace terms. Toggle "Use regex" if you are using regular expressions.
  2. Apply to Text:
    • Open any note in Obsidian.
    • Targeted: Highlight a specific block of text to only apply the replacement to your selection.
    • Document-wide: Leave your cursor unselected to apply the replacement to the entire note.
  3. Execute:
    • Right-click the editor and select your action from the Custom replace context menu.
    • Alternatively: Open the Command Palette (Ctrl/Cmd + P), type your action's name, and hit Enter.
  4. Undo:
    • Made a mistake? Press Ctrl/Cmd + Z once to undo the entire action instantly.

Installation

From the Community Plugins List (Recommended)

  1. Open Obsidian and navigate to Settings → Community plugins.
  2. If Restricted mode is enabled, click Turn off to allow third-party plugins.
  3. Click Browse and search for Replace Commands.
  4. Click Install, and then click Enable.

Manually installing the plugin

To install the plugin manually from GitHub:

  1. Download the latest release from the GitHub Releases page.
  2. Extract the files and copy main.js, manifest.json, and styles.css to your vault at YourVaultFolder/.obsidian/plugins/replace-commands/.
  3. Open Obsidian, go to Settings → Community plugins, and toggle on Replace Commands.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for details on how to set up the development environment and the contribution guidelines.

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.