edit
Replace text in files with smart indentation and encoding detection. Preview changes with dry-run before saving.
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
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | No | Absolute path to the file to edit | |
| path | No | Alias for file_path | |
| old_string | No | Exact text to find in the file | |
| new_string | No | Replacement text (must differ from old_string) | |
| old_content | No | Alias for old_string | |
| new_content | No | Alias for new_string | |
| replace_all | No | Replace all occurrences instead of just the first: true or false. Default: false | |
| dry_run | No | Preview changes without modifying the file: true or false. 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). |