Skip to main content
Glama

AHK_File_Edit_Small

Make targeted edits to AutoHotkey files with regex or literal replacements, line operations, multi-file batches, and optional previews for lightweight modifications.

Instructions

Token-efficient editor for small, targeted changes. Ideal when you need a lightweight replace or line edit without loading the full diff engine. Supports regex and literal replacements, multi-file batches, optional diff previews, and dry-run mode.

Common Replace

{ "action": "replace_literal", "file": "C:\\Scripts\\MyScript.ahk", "find": "Sleep(500)", "replace": "Sleep(100)" }

Insert Before a Line (Preview)

{ "action": "line_insert_before", "file": "C:\\Scripts\\TrayMenu.ahk", "line": 42, "newContent": " TrayTip(\"Menu refreshed\")", "dryRun": true }

Multi-File Regex Replace

{ "action": "replace_regex", "files": ["core.ahk", "ui.ahk"], "find": "SetTimer\\((\\w+), 5000\\)", "replace": "SetTimer($1, 10000)", "all": true }

What to Avoid

  • Mixing deprecated "content" parameter with newContent - prefer newContent

  • Running multi-file edits without dryRun: true to preview

  • Forgetting backup: true when touching critical scripts

See also: AHK_File_Edit (full-featured editor), AHK_File_Edit_Diff (complex diffs), AHK_File_Edit_Advanced

πŸ“Ž Active File: Not set. Use AHK_File_Active to select a target.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionNoEdit action to perform (default: replace_literal for safe string matching)replace_literal
fileNoTarget file to edit. Defaults to the active file when omitted.
filesNoApply the same edit to multiple files.
findNoText (or pattern) to search for when using replace actions.
replaceNoReplacement text for replace actions.
regexFlagsNoAdditional RegExp flags (e.g. "i" for case-insensitive).
allNoReplace all occurrences (false = first only).
lineNoLine number for line-based actions (1-based).
startLineNoStart line for range operations (1-based).
endLineNoEnd line for range delete or replace (1-based, inclusive).
contentNo⚠️ Deprecated alias for newContent. Prefer newContent for new text.
newContentNoContent to insert or replace when using line actions. Example: "MsgBox(\"Done\")".
previewNoShow a unified diff instead of writing to disk.
dryRunNoPreview changes without modifying file. Shows affected lines and change count.
backupNoCreate a .bak backup before writing changes.
runAfterNoRun the script after edits complete (single file only).

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