Copy Notepad++ text with formatting?
Solution 1
Here is an image from notepad++ when you select text to copy as html.
and how the formatted text looks like after pasting it in OneNote (similar to any other app that supports "Paste Special"):
Solution 2
Taken from here:
You can use Notepad++ to accomplish this in three ways. Just so you know, Notepad++ is a more advanced version of Notepad, which supports syntax highlighting of different code files "out of the box" - PHP included!
Download & install it, fire it up, and load up your PHP file. You should automatically see it beautifully coloured (if not, because the file extension is something other than .php, go to Language -> PHP or Language -> P -> PHP).
If you need to change any of the colours, you can easily do so - just go to Settings -> Styler Configurator. From that menu, you can change the various highlighting and font options, to suit your needs - although the default usually suffices for most.
Then, go to Plugins -> NppExport. From there, you have three options you can consider:
Export to RTF Export to HTML Copy all formats to clipboard Start with the last one - "Copy all formats to clipboard" - which will copy the entire file with the highlighted syntax to the clipboard. Once you click it, then open Microsoft Word, and just hit paste! You should see the beautifully syntax-highlighted code. If something goes wrong, then you can try one of the other options (export to RTF/HTML), although I've never had a problem with the clipboard method.
Solution 3
Select the Text
From the menu, go to Plugins > NPPExport > Copy RTF to clipboard
In MS Word go to Edit > Paste Special
This will open the Paste Special dialog box. Select the Paste radio button and from the list select Formatted Text (RTF)
You should be able to see the Formatted Text.
Solution 4
Select the text.
Right Click.
Plugin Commands -> Copy Text with Syntax Highlighting
Paste it into Word or whatever.
Solution 5
It is worth mentioning that 64-bit Notepad++ does not support Plugin Manager and NPPExport, so they won't be shown in Plugins menu. If you will try to add NPPExport plugin manually, most likely you'll see :
"NPPExport plugin is not supported with 64bit Notepad++"
Fortunately, there is NPP_Export plugin to download from here which works well with 64-bit Notepad++ (v7.2.2 in my case) and support for Plugin Manager is underway (check GitHub for updates).
Related videos on Youtube

Josh
Updated on March 18, 2022Comments
-
Josh 9 months
I'm using Notepad++ to write code.
How do I copy code in Notepad++ along with its formatting to paste into Microsoft Word? (i.e. syntax highlights, etc)
-
Ungeheuer over 4 yearsPossible duplicate of Syntax highlighting in MS Word document
-
-
Dennis G about 10 yearsAnd now go to [Settings > Shortcut Mapper > Plugin Commands > Copy all Formats to clipboard] and set it to CTRL+SHIFT+C --> Instant joy. CTRL+C to copy the raw text, CTRL+SHIFT+C to copy with formatting. This should be default.
-
Mohammad Fanni over 8 yearsfor paste with formatting use CTRL+SHIFT+V in libreOffice writer
-
Pacerier over 7 years"Export to HTML" works but not "Copy HTML to clipboard". Do you know why?
-
Pacerier over 7 years@DennisG, Instant joy, until you are at your colleague's desk (or anyone else for that matter) and you found yourself so used to CTRL+SHIFT+C that you've forgotten where the original setting is located. Whoops.
-
Mark Miller over 6 yearsThis worked for me except I was trying to preserve formatting in a
Notepad
file instead of anMSWord
file. I had to copy the code fromNotepad++
, paste it intoMSWord
and then copy it fromMSWord
and paste it intoNotepad
. For some reason I could not paste it directly intoNotepad
. -
The Beast about 6 yearsA shortcut is to use: Ctrl + Shift + C. Settings > Shortcut Mapper > Plugin Commands > Copy all Formats to clipboard. > CTRL+SHIFT+C --> Happy formatting !
-
Kyle Strand almost 6 years@Pacerier As of 7.2.2 "Copy HTML to clipboard" seems to work just fine.
-
BobNoobGuy over 5 yearsanyone loose Line Feed using this method?
-
Joe Greene over 5 years@BobNoobGuy I am when I try to use "Copy HTML to Clipboard" (I'm on 7.2.2). Although hackish, the way I preserve line feed is by exporting to HTML, opening the HTML in Word, then copying from there to whichever source I need to send code to (e.g. OneNote).
-
underscore_d about 5 yearsWhat DLL would that be?
-
Homer about 3 yearsthis method is no longer preserving the format color
-
deasserted over 2 yearsNppExport version 0.2.8 was not pasting the syntax formatting colors for me. I am happy that updating to 0.2.9 fixed the colors. :-)
-
Erdem KAYA almost 2 yearsThis is quite helpful, however, in my case, line endings and font types are not saved.
-
AdrianHHH over 1 yearThe images appear to show the results of your solution, but you have not described your solution or how to use it!
-
baobab159 9 monthsI updated the description