edit
Replace text in files while preserving indentation style and encoding. Automatically converts between tabs and spaces, reads .editorconfig settings, and offers dry-run previews.
Instructions
Replaces old_string with new_string in the specified file. Smart indentation: auto-converts between tabs and spaces to match the file's style. Encoding-aware: preserves original file encoding (UTF-8, EUC-KR, Shift-JIS, UTF-8 BOM, etc.). Reads .editorconfig for indentation settings. Use dry_run=true to preview changes without modifying the file.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | Absolute path to the file to edit | |
| old_string | Yes | Exact text to find in the file | |
| new_string | Yes | Replacement text (must differ from old_string) | |
| replace_all | No | Replace all occurrences instead of just the first (default false) | |
| dry_run | No | Preview changes without modifying the file (default false) | |
| indent_style | No | Override indentation style. Values: tabs or spaces-N (e.g. spaces-4). Empty = auto-detect (default) | |
| expected_hash | No | Optional SHA-256 hash of the file. If provided and mismatched, edit is rejected (optimistic concurrency). |