Skip to main content
Glama

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

{ "action": "replace", "search": "oldClassName", "newContent": "NewClassName", "filePath": "C:\\Scripts\\MyAutomation.ahk" }

Batch Replace with Regex (Preview First)

{ "action": "replace", "search": "class\\s+(\\w+)", "newContent": "class Refactored$1", "regex": true, "all": true, "dryRun": true }

Shows a DRY RUN report instead of touching the file.

Create New Script

{ "action": "create", "filePath": "C:\\AHK\\Helpers\\ClipboardTools.ahk", "newContent": "class ClipboardTools {\n __New() {\n ; init\n }\n}" }

What to Avoid

  • Using deprecated "content" parameter - migrate to "newContent"

  • Running batch replacements without dryRun: true first

  • Disabling 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

TableJSON Schema
NameRequiredDescriptionDefault
actionNoEdit action to performreplace
searchNoText to search for (for replace/delete)
newContentNoPreferred parameter containing the replacement or inserted text (e.g., "MsgBox(\"Updated\")").
contentNo⚠️ Deprecated alias for newContent. Will be removed in a future release.
lineNoLine number for insert/delete (1-based)
startLineNoStart line for range operations
endLineNoEnd line for range operations
filePathNoFile to edit (defaults to activeFilePath)
regexNoUse regex for search
allNoReplace all occurrences
backupNoCreate backup before editing
runAfterNoRun the script after the edit completes successfully
dryRunNoPreview changes without modifying file. Shows affected lines and change count.
validateNoValidate AHK code before writing. Blocks edit if syntax errors are found.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TrueCrimeDev/ahk-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server