Last updated on November 9th, 2020 at 09:43 pm
Writing good documentation for technical processes is a critical function that even coders can't avoid. And since Microsoft Word is the standard for documents, it's inevitable you'll need to at least drop the occasional code snippet into a Word document at some point.
Why Notepad++ as an option? Well, Microsoft Word isn’t exactly the first program one might think of when it comes to writing code. While Word can do a lot of things, code editing isn’t what it’s designed for. Nevertheless, writing good documentation for technical processes is a critical function that even coders can’t avoid. And since Microsoft Word is the standard for documents, it’s inevitable you’ll need to at least drop the occasional code snippet into a Word document at some point.
But dropping code into MS Word sucks.
If you’ve made it this far, it’s safe to say you got here looking for a clean way to get your code snips and scripts into a Microsoft Word document. You’d probably even want to retain syntax highlighting right? So let’s get into it…
The key to displaying code that looks good starts with the editor you use to write the code. Notepad++ is a great source code editor that supposed syntax highlighting for dozens of languages.
If you write code and scripts, you probably already know Notepad++ but if not, you can get it here.
Once it’s installed, type in your code, pick the language and all the syntax will be highlighted appropriately.
Notepad++ comes in both 32-bit and 64-bit flavors. I happen to prefer the 64-bit version, but there’s a catch…
Installing the NppExport Plugin
Notepad++ supports a ton of different plugins that give added functionality. You can use the help menu to be taken to Notepad++ Plugin Central but unfortunately, only the 32-bit version of NPPExport is available there.
If you installed the 64-bit version of Notepad++, you’ll need to head over to Github to snag the 64-bit version.
All you need to do is copy the NppExport.dll file from the download and drop it into your Notepad++ plugin directory. Unless you customized your install, it’ll be located at C:\Program Files\Notepad++\plugins.
The next time you open Notepad++, the plugin will be available.
Copying Text and Syntax Highlighting
Now that all the tools are in place, all you need to do is highlight the section of code you want to copy. Right-click the selection and then mouse-over Plugin Commands from the context menu. In the submenu, click Copy Text with Syntax Highlighting.
Once that’s it, you just paste into Microsoft Word like you normally would and voila! All of your code with its pretty syntax is laid out in your Word document.
Folks in the technology industry spend a good amount of their time writing documentation. With the help of Notepad++ and the NppExport plugin, you can use the industry standard documentation software without sacrificing the syntax of your code snippets.