How to Paste Code Into Word, Email, and Chat Without Wrecking It
By Khushi Yadav
Code is text that cannot tolerate typographic kindness. A straight quote that becomes a curly quote is a syntax error. A ligature, a non-breaking space, or an optional hyphen is a syntax error. Word and Outlook are built to apply that kindness. This guide is how to paste a snippet into those surfaces — and when to refuse and send a gist or a file instead.
What Word will do to a paste
Microsoft documents Keep Source Formatting as the usual Ctrl+V default from other programs. From VS Code or a webpage that often means:
- A proportional font (Calibri, Aptos) instead of Consolas / Cascadia
- Colored HTML spans from a highlighter
- Smart quotes if AutoFormat is on when Word edits the paste
- Soft wraps that look like extra line breaks
Microsoft’s smart-quotes article: Word can replace straight ' and " with curly quotes as you type. The setting lives under File > Options > Proofing > AutoCorrect Options > AutoFormat As You Type > "Straight quotes" with “smart quotes”. Pasted code that Word then “helps” will rot.
Paste path that stays compiling
- In Word, paste with Keep Text Only (Ctrl+Shift+V in current Microsoft 365 Word, or Home > Paste > Keep Text Only). Official definition: discards formatting and nontext elements; text takes the destination style.
- Apply a monospaced paragraph style (create
Codebased on Normal, font Consolas or Cascadia Mono, no smart quotes, no automatic hyperlinks if possible). - If the snippet is more than a few lines, use a one-cell table or a borderless box so line breaks do not reflow as body text.
If Ctrl+Shift+V is unbound: Ctrl+Shift+V Does Not Work Everywhere.
Turn off the traps for the session
- AutoFormat As You Type: straight quotes → smart quotes off
- AutoFormat As You Type: hyphens → dash off (or
--becomes an em dash mid-flag) - AutoCorrect: entries that expand
tehare fine; entries that touch(c)or quotes are not
Details: Smart Quotes, Em Dashes, and Other Paste Traps.
Ctrl+Z immediately after a paste that “looked helpful” often undoes AutoFormat. Do not rely on noticing.
Outlook
Desktop Outlook uses Word as the editor. The same Keep Text Only and AutoCorrect settings apply (Outlook: File > Options > Mail > Editor Options). HTML mail will still wrap. For anything a recipient might compile:
- Attach a
.py/.cs/.jsonfile, or - Link a gist / repo, or
- Use a monospaced paragraph and Keep Text Only
Do not paste a 200-line stack trace into an HTML signature-adjacent body and expect indentation to survive every client.
Google Docs
Ctrl+Shift+V pastes without formatting (Docs shortcut list). Then apply a Courier / Consolas style. Docs will still reflow. For review comments, a gist link is kinder than a 80-line code paragraph.
Copying the other direction (Docs → Word) adds spans: Copying From Google Docs to Word Without Chaos.
Slack, Teams, Discord
Slack: wrap in a fenced code block or create a snippet (Ctrl+Shift+Enter). Line-break rules: How to Keep Line Breaks When Pasting Into Slack. Slack’s own help covers code and snippets.
Teams: Ctrl+Shift+V for text, then the code-block control in the compose toolbar when available. Prefer a file for long traces.
Discord: triple backticks. Watch Enter-to-send.
HTML from a syntax-highlighted webpage will paste as colored text in some clients and as a mess in others. Copy from the editor (plain) or from a raw gist view, not from a pretty blog.
Hidden characters that are not quotes
Web and PDF copies inject soft hyphens and ZWSP. They survive Keep Text Only. A function name with U+00AD in the middle will not grep. Strip them: Strip Tracking and Soft Hyphens From Copied Text.
Indentation, tabs, and mail clients
Even a Keep Text Only paste can lose leading spaces if the destination collapses whitespace. HTML mail is the usual villain: multiple spaces become one. A monospaced paragraph style does not always disable that collapse.
Mitigations, in order:
- Attach a file.
- Use a one-cell table with a monospaced font and do not let the client convert it to a paragraph.
- Replace leading spaces with a visible indent the team accepts (not ideal).
- For two-line commands, a single line with
&&may survive better than a wrapped script — only if it remains correct.
Tabs versus spaces: Word may convert tabs to the default tab stops (every 0.5"). A Python file that mixed tabs and spaces will look “fine” and then fail. Copy from an editor that shows whitespace, or attach the file.
When to refuse the paste
Send a file or gist when any of these are true:
- More than ~30 lines
- The recipient must run the code
- The surface is a paginated Word report
- The snippet includes secrets (do not paste those at all; rotate)
Clipboard history will keep a copied secret as one of 25 items until eviction, delete, or restart (unpinned). Do not pin code that contains tokens. Clear: How to Clear Clipboard History on Windows 11.
Reusable command lines (kubectl …) belong in an expander, not in a pin: When You Need Snippets, Not Clipboard History.
Line endings CR, LF, and email
Windows text uses CR+LF. Unix repositories use LF. Some mail clients display a stray ^M or double-space every line after a paste. If the snippet came from GitHub’s web UI, line endings are usually LF and Slack/Teams are fine. If it came from Notepad “Save as UTF-8” on Windows, CR+LF is normal.
If a paste into Outlook shows a blank line between every line, the client is treating LF and CR as two breaks. Paste into Notepad, save, reopen, copy again — or attach the file. Do not “fix” it by deleting every other line by hand in a 200-line trace.
Syntax-highlighted blogs are a hostile source
Copying from a documentation site that uses a <pre> with span-per-token HTML is how Word acquires 40 colors. Always prefer:
- The raw view on GitHub/Gist
- The editor’s buffer
- “Copy raw file” if the host offers it
If the only source is the pretty page, Notepad scrub once, then paste. Do not Keep Source “so the highlighting remains.” Highlighting is not meaning; it is decoration that becomes a support burden.
History is a poor gist
Win+V can retrieve the last few copies in a session (4 MB, text/HTML/bitmap, restart wipe except pins). It cannot syntax-highlight, cannot comment, and cannot be attached to a PR. Use it to recover “the version before Word ate the quotes,” then save a file.
A local shelf such as Edge-Drop can hold a .log file for drag into the ticket. That is a file job, which OS history will not do.
Related reading
- Smart Quotes, Em Dashes, and Other Paste Traps
- Copying From Google Docs to Word Without Chaos
- How to Paste Without Formatting on Windows
- A Sensible Daily Copy-Paste Workflow
Sources
- Control the formatting when you paste text (Microsoft Support) — Keep Text Only.
- Smart quotes in Word and PowerPoint (Microsoft Support) — AutoFormat As You Type path.
- Paste Text Only shortcut in Word (Microsoft 365 Insider) — Ctrl+Shift+V.
- Format your messages in Slack — code and code blocks.
- Using the clipboard (Microsoft Support) — history is a short, non-secret-safe recents list.
Khushi Yadav is a B.Tech Computer Science Engineering student interested in technology, software, and exploring practical applications of computer science. She enjoys learning new concepts and contributing to technology-focused projects.
GitHub · LinkedInCopy. Stack. Drop.
Transform your clipboard into an interactive edge shelf. Stack, pin, and drag assets into any app with zero friction.
Download for Windows Get from Microsoft Store
How to Install Guide · First 10 Minutes Guide · Drag & Drop Guide · Edge-Drop vs Win+V · Support
Free · Lightweight · Privacy First