Document Editing Problems

How to Keep Syntax Highlighting When Pasting Code into OneNote

John WilsonJohn Wilson Oct 15, 2026 869 views

Question details

User needs a way to paste programming code from a code editor into OneNote without losing the colors and formatting of the syntax highlighting.

How to Keep Syntax Highlighting When Pasting Code into OneNote
Product
OneNote for Windows 10
Device & OS
Windows 10
Scenario
Copying source code from a development environment (like Code Composer Studio) and pasting it into a notebook for documentation.
Observed behavior
The syntax highlighting and rich formatting are stripped out, leaving only plain, unformatted text when pasted into OneNote.
Before you start

Ensure your specific code editor supports copying text with rich formatting (RTF or HTML). If the editor only copies plain text to the clipboard, no destination app will be able to display the syntax colors.

Solution 1Recommended

Use Microsoft Word or WPS Writer as a Formatting Bridge

Paste the code into a robust word processor first to lock in the clipboard formatting, then transfer it to OneNote.

OneNote's clipboard processor sometimes struggles to interpret the raw HTML/RTF data coming directly from certain IDEs like Code Composer Studio. Word processors have more advanced clipboard handling and can reliably interpret these formats.

1
Copy from your IDE

Highlight your code in your programming editor and press Ctrl + C to copy it.

2
Paste into a Word Processor

Open a new blank document in Microsoft Word or WPS Writer. Right-click the page and select 'Keep Source Formatting' under the Paste Options to paste your code.

3
Transfer to OneNote

Select the newly pasted and colored code in the word processor, press Ctrl + C to copy it again, and then paste it directly onto your OneNote page.

Use Microsoft Word or WPS Writer as a Formatting Bridge
Formatting Retained: This bridging method almost always ensures that the rich text data is reformatted into a standard structure that OneNote can easily understand.
Free Microsoft Office alternative

Try WPS Writer for Better Code Documentation

If Microsoft Office applications are causing clipboard headaches, WPS Office provides a lightweight, seamless alternative. WPS Writer perfectly retains rich text formatting, including syntax highlighting from popular code editors, making it an excellent tool for developers creating technical documentation.

  1. 1. Install WPS Office: Download and install the free suite from the official WPS website.
  2. 2. Copy the Code: Highlight and copy the target code from your preferred code editor.
  3. 3. Paste into WPS Writer: Open a new Writer document and press Ctrl+V. The syntax highlighting will be preserved flawlessly.
Perfectly preserves syntax highlighting and rich text when pasting from most IDEs.Fully compatible with Microsoft Word (.docx) formats.Tabbed interface allows you to manage multiple code documents efficiently.Completely free to download and lightweight on system resources.
microsoft office alternative - wps office

Frequently Asked Questions

Why does OneNote sometimes paste code as plain text?

This usually happens if the source IDE places plain text on the system clipboard rather than HTML/RTF data, or if OneNote's default paste setting is configured to 'Keep Text Only'.

Can I use a OneNote add-in to format source code directly?

Yes. If your editor won't export colors properly, you can use third-party OneNote add-ins like NoteHighlight or OneMore to generate syntax highlighting natively inside OneNote.

Does pasting into OneNote for Web retain formatting better?

Because web browsers process clipboard HTML differently than Windows desktop apps, pasting into the OneNote Web version sometimes bypasses desktop clipboard bugs and retains colors perfectly.