If you’ve ever tried copy-pasting source codes into a Word document, you know what a nightmare it is to apply syntax highlighting. Most probably, you have to manually apply colors on sections of source code. While searching for a solution, I came to know about a Notepad++ plugin NppExport that’ll help you copy code from Notepad++ and paste it in Microsoft Word with syntax-coloring attached.

If you haven’t got a copy of Notepad++, download it from their download page. After installing it on your machine, launch Notepad++ and copy-paste this Python source code into a new file:

Now go to Language > P > Python to apply syntax highlighting for Python code. You can select other languages depending on your requirements. You’ll notice that the source code is now colorful. Now go to Plugins > NPPExport > Copy all formats to clipboard. Selecting this option saves a copy of the selected source code in the clipboard. Launch Microsoft Word and press Ctrl + V to paste the copied source code. Here is how it looks like in Microsoft Word:


If you’re aware of any other method, do let me know in your comments.

Tagged with →  
Share →
%d bloggers like this: