← Back to Blog

Developers & Code | Published Aug 21, 2026 | Updated Oct 13, 2026 | 6 min read

How to Paste Code Into Word, Email and Chat

By Deepender Yadav

How to Paste Code Into Word, Email and Chat — Edge Drop Guide

To paste code into Word, press Ctrl+Shift+V (Paste Text Only in current Microsoft 365 Word) or paste and choose Keep Text Only, then apply a monospaced font such as Consolas. That keeps the characters exactly as they were. If you will keep editing the code in Word, also turn off "Straight quotes" with "smart quotes" so new quotes you type don't curl. In chat apps, use a code block; for anything long or meant to be run, send a file or a gist.

Why code breaks in Word and email

Word and Outlook are built for prose, and three things go wrong when code lands in them:

  • Formatting comes along. Word's default paste is Keep Source Formatting, so a copy from a web page or a highlighted editor brings fonts, colours and line spacing with it.
  • Typing rewrites characters. AutoFormat As You Type changes characters as you type them: straight quotes become curly, -- becomes a dash, and 1/2 becomes ½. A curly quote or an em dash in code is a syntax error.
  • Long lines wrap. A proportional font and narrow page margins wrap long lines, which makes the code hard to read and easy to retype wrongly.

AutoFormat As You Type works on what you type, not on what you paste, so a clean text-only paste stays clean. The damage usually happens later, when someone edits the snippet in place.

Paste code into Word

  1. Copy the code from your editor, not from a styled web page if you can avoid it.
  2. In Word, press Ctrl+Shift+V. If your version doesn't support it, press Ctrl+V, then press Ctrl to open the Paste Options menu and choose Keep Text Only.
  3. Select the pasted lines and apply a monospaced font such as Consolas or Cascadia Mono. For repeated use, create a paragraph style called "Code" with that font and no space between paragraphs.
  4. Check the indentation. Tab characters are kept as tabs; Word just displays them at its tab stops, so the alignment can look different from your editor even though the characters are unchanged.

Keep Text Only discards fonts and colours and takes on the style of the paragraph you paste into. If the shortcut does nothing, Ctrl+Shift+V does not work everywhere lists the alternatives.

If you want the syntax colours

VS Code copies code with its syntax highlighting by default. Paste with plain Ctrl+V (Keep Source Formatting) and Word keeps the colours and the editor font. That suits a report or a slide that people will read but not run. If you'd rather always get plain text from VS Code, turn off Copy With Syntax Highlighting in its settings; the VS Code clipboard guide has more on the editor side.

Stop Word changing code you edit

If you will type inside the code in Word, open File > Options > Proofing > AutoCorrect Options, select the AutoFormat As You Type tab, and clear these boxes under Replace as you type:

  • "Straight quotes" with "smart quotes"
  • Hyphens (--) with dash (—)
  • Fractions (1/2) with fraction character (½)
  • Internet and network paths with hyperlinks

If Word changes something as you type, press Ctrl+Z straight away to undo just that change. How to turn off smart quotes in Word covers these settings and how to straighten quotes that are already curly.

Paste code into an email

Classic Outlook for Windows uses the same editor as Word, so the steps above apply: paste as text, set a monospaced font, and change the AutoCorrect options under File > Options > Mail > Editor Options.

In Gmail, paste with Ctrl+Shift+V (plain text in Chrome and Edge) and pick the Fixed Width font from the formatting bar.

Email is still a poor way to send code someone will run. Mail apps can rewrap long lines and the recipient's client decides how it looks. For more than a few lines, attach the file or send a link.

Paste code into Slack, Teams and Discord

  • Slack: select the text and use the Code block button in the formatting toolbar, or wrap it in triple backticks. For long code, type or paste it and press Ctrl+Shift+Enter to turn it into a snippet with syntax highlighting. If line breaks go missing, see how to keep line breaks when pasting into Slack.
  • Teams and Discord: wrap the code in triple backticks to get a code block.

Copy from your editor or from the raw view of a file. Highlighted code copied from a documentation site often carries HTML that the chat app renders differently or strips.

Check for characters that look right but aren't

Code that has passed through a web page, a PDF or a word processor can pick up characters that look identical to the right ones:

Looks likeActually isTypical source
"Curly quotes U+201C / U+201DWord, Google Docs, blogs
-En dash U+2013 or minus sign U+2212Word, PDFs
spaceNon-breaking space U+00A0Web pages
nothingSoft hyphen U+00AD or zero-width space U+200BWeb pages, PDFs

Keep Text Only removes formatting, not characters, so these survive a plain-text paste. In Word, select a suspicious character and press Alt+X to see its Unicode code. How to strip soft hyphens and other hidden characters shows how to remove them in bulk.

When to send a file or gist instead

Paste a snippet when people only need to read a few lines. Send a file or a link when:

  • the code is longer than about a screen,
  • the recipient needs to run it, so every character has to survive,
  • it's going into a paginated document where wrapping will mangle it.

A gist is the quickest link to share; with the GitHub CLI installed, gh gist create script.py creates one from a file. Gists or the clipboard for throwaway code compares the options. Never paste secrets into any of these places: an API key in an email or chat thread is out of your control. Is an API key on the clipboard a security incident? explains what to do if it happens.

FAQ

What font should I use for code in Word?

Any monospaced font works. Consolas ships with Windows and Office; Cascadia Mono is the Windows Terminal font. Courier New also works but is lighter and harder to read on screen. Column-aligned output, such as a hex dump that has to keep its alignment, only lines up in one of these fonts.

Why does my pasted code have curly quotes?

Either the source already had them (common when copying from blogs or documents) or Word changed them as you typed. Pasting as text doesn't straighten existing curly quotes; replace them, or copy again from the original source file.

Can I keep line numbers when pasting code into Word?

Line numbers in editors and on code-hosting sites are usually display only and don't copy. For a numbered listing, Word's own line numbering (Layout > Line Numbers) can number the paragraphs instead.

Related reading

Sources

Deepender Yadav
Written by Deepender Yadav · Creator & Developer

Deepender Yadav created Edge Drop and builds and tests it, from the edge-hover shelf to each release. A B.Tech Computer Science Engineering student, Deepender writes the Edge Drop guides, comparisons and developer posts, and checks product details against the app's source code.

GitHub · LinkedIn

Copy. 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
Find us on CodeHype