Edit a Google Doc
edit_docReplace selected text in a Google Doc with new content, supporting markdown and inline HTML formatting. Applies changes directly as live text for quick document updates.
Instructions
Replace an exact unique snippet of text in a Google Doc (like a local file Edit). old_string is matched markup-tolerantly; ambiguous matches return surrounding context to disambiguate. new_string is interpreted as inline markdown and inline HTML (bold, italic, code, text, <u>, <span style="color:…;font-size:…pt">) — the same spelling read_doc emits, so a read can be edited and written back. To restyle text you are NOT otherwise changing, use set_style instead: it needs no copy of the text. NOTE: this is a direct edit — the change is applied as live text, not a tracked suggestion (the Docs API cannot create suggestions). If the doc has pending suggestions from other reviewers, flag to the user that your edit will sit alongside them as an accepted change.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tab | No | Target a specific tab by tabId or title (from list_tabs). Defaults to the first tab. | |
| page | No | which header/footer, when a doc defines more than one (default-page, first-page, even-page). Omit to use whichever exists. | |
| account | No | Google account email to use. Defaults to GDOCS_DEFAULT_ACCOUNT, or the sole account. | |
| segment | No | which content tree to target: body (default), or the page header/footer. Header/footer content is invisible to a body read — a letterhead logo lives there. | |
| documentId | Yes | Google Doc id | |
| new_string | Yes | replacement text | |
| old_string | Yes | exact text to replace (quote a unique slice from read_doc) | |
| replace_all | No | replace every occurrence (default false) |