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)
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)
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"):
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.
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.
Select the text.
Right Click.
Plugin Commands -> Copy Text with Syntax Highlighting
Paste it into Word or whatever.
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).
It seems to me that the best and easiest way is commented by Dennis G:
And 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.
Hoping help someone just like me!
Horrible to look for this failure:
Copy .dll to here:
\Program Files\Notepad++\plugins --> put it here
Restart the notepad++
and now you are able to use the copy commands!!!