# Features `email.sublime-syntax` turns raw emails into readable, easy-to-navigate documents in **Sublime Text 4** and in the terminal with **[bat](https://github.com/sharkdp/bat)**. ## Syntax Highlighting - **Headers**: Distinguishes standard headers (`From`, `To`, `Subject`, `Date`, `Message-ID`), custom `X-*` headers, and authentication headers (`DKIM`, `SPF`, `ARC`). - **Delivery Traces (`Received:`)**: Highlights relay hops, hostnames, protocols (`ESMTP`, `ESMTPS`), queue IDs, relay IPs, TLS details, and timestamps across single- and multi-line headers. - **International Text**: Highlights encoded headers and subjects across UTF-8, European, Cyrillic, and East Asian charsets. - **Addresses, Links & Encodings**: Highlights email addresses, URLs, IPv4/IPv6 addresses, timestamps, Quoted-Printable sequences, and Base64 blocks. - **Theme-Friendly**: Uses standard Sublime Text scopes so highlighting adapts naturally to any dark or light color scheme. ## Multipart & Embedded Formats - **Nested MIME & Single-Part Messages**: Cleanly delimits multi-level multipart trees while accurately handling standalone HTML, XML, Base64 image, Quoted-Printable, and plain-text emails. - **Embedded Languages**: Automatically highlights embedded **HTML** (including Quoted-Printable HTML in Sublime Text 4), **XML**, **calendar invites** (`.ics`), **diffs & patches** (`.diff`/`.patch`), and **attached emails** (`.eml`). ## Hover Previews *(Sublime Text 4)* - **Inline Images**: Hover over Base64 image blocks to preview `PNG`, `JPEG`, `GIF`, `WebP`, `BMP`, `ICO`, and `SVG` images inline. - **Base64 Text**: Hover over Base64 text blocks to preview the first 50 decoded lines without modifying the file. - **Time Zone Conversion**: Hover over any timestamp to view both **local time** and **UTC**. - **Fast on Large Files**: Inspects only the block under your cursor to stay responsive on multi-megabyte emails. ## Built-in Commands *(Sublime Text 4)* Available from the **Command Palette** (`Cmd+Shift+P` / `Ctrl+Shift+P`) and the **right-click context menu**: - **Email: Decode Base64**: Decodes Base64 text blocks in place, with binary safeguards to avoid corrupting the buffer. - **Email: Decode Encoded-Words**: Decodes encoded header text into readable Unicode in place across a line, selection, or folded header. - **Email: Decode Quoted-Printable**: Unwraps soft line breaks and decodes `=XX` Quoted-Printable text or HTML bodies in place using the part's declared charset. - **Email: Export Attachment to File**: Exports binary or text-based attachments directly to disk with automatic filename and extension detection. ## Navigation, Folding & Editing *(Sublime Text 4)* - **Code Folding**: Fold wrapped headers, multi-line comments, individual MIME parts, Base64 attachment blocks, and indented HTML/XML from the gutter. - **Message Outline (`Goto Symbol`)**: Press `Cmd+R` / `Ctrl+R` to jump straight to `Header Section`, `Message-ID`, `Multipart` containers, `Part` bodies, and named `Attachment` entries. - **Cross-File Lookup (`Goto Symbol in Project`)**: Press `Cmd+Shift+R` / `Ctrl+Shift+R` to find any email across a folder by `Message-ID`. - **Comment Toggling**: Press `Cmd+/` / `Ctrl+/` to toggle reply quoting (`> `) or header comments (`( ... )`). ## Sublime Text 4 vs. `bat` | Capability | Sublime Text 4 | `bat` | | --- | :---: | :---: | | Headers, `Received:` traces, links, IPs & timestamps | Yes | Yes | | International text & nested MIME parts | Yes | Yes | | Embedded HTML, XML, `.ics`, `.diff`/`.patch` & `.eml` | Yes | Yes | | Embedded Quoted-Printable HTML | Yes | Plain text fallback\* | | Code folding, `Goto Symbol` & comment toggling | Yes | — | | Hover previews & decode/export commands | Yes | — | *\*Quoted-Printable HTML uses Sublime Text 4 syntax inheritance, which `bat`'s engine does not yet support.*