AHK_File_Edit
Edit AutoHotkey files directly to perform search/replace, insert lines, create new scripts, or delete content with regex support and preview options.
Instructions
Primary AutoHotkey file editor for direct on-disk modifications. Handles search/replace, line inserts, deletes, appends, prepends, and even new file creation. Supports regex, automatic backups, dry-run previews, and optional script execution after edits.
Common Usage
Batch Replace with Regex (Preview First)
Shows a DRY RUN report instead of touching the file.
Create New Script
What to Avoid
Using deprecated "content" parameter - migrate to "newContent"
Running batch replacements without
dryRun: truefirstDisabling backups on production files unless absolutely necessary
See also: AHK_File_Edit_Advanced, AHK_File_Edit_Small, AHK_File_View, AHK_Smart_Orchestrator
π Active File: Not set. Use AHK_File_Active to select a target.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | No | Edit action to perform | replace |
| search | No | Text to search for (for replace/delete) | |
| newContent | No | Preferred parameter containing the replacement or inserted text (e.g., "MsgBox(\"Updated\")"). | |
| content | No | β οΈ Deprecated alias for newContent. Will be removed in a future release. | |
| line | No | Line number for insert/delete (1-based) | |
| startLine | No | Start line for range operations | |
| endLine | No | End line for range operations | |
| filePath | No | File to edit (defaults to activeFilePath) | |
| regex | No | Use regex for search | |
| all | No | Replace all occurrences | |
| backup | No | Create backup before editing | |
| runAfter | No | Run the script after the edit completes successfully | |
| dryRun | No | Preview changes without modifying file. Shows affected lines and change count. | |
| validate | No | Validate AHK code before writing. Blocks edit if syntax errors are found. |