Is it possible to embed programming source code to Powerpoint slide, and keep code highlighting/coloring?
-
what application are you copying from? – John T Dec 21 '09 at 04:26
-
I use textmate, e-texteditor and eclipse the most. – Yousui Dec 21 '09 at 04:58
11 Answers
After pasting, a small "Paste Options" icon appears below the pasted text.
Click this icon and choose "Keep Source Formatting" :

-
3I don't see such a `Paste Options` icon. I don't see a button to give me these options. I'm using PowerPoint:mac 2011. I think I have seen it in Windows versions, however. – Asclepius Jul 19 '13 at 21:49
-
I tried different suggested methods and tools to copy from, but was actually missing that word/powerpoint was messing up the format by using "Destination Theme". Thanks! – Tim Büthe Jan 22 '14 at 11:23
Use Notepad++ with add-on NppExport.
Select the source code
Use Copy RTF to clipboard of NppExport
Paste into empty PPT slide (do not select any textfiled)
-
8With version 6.9.2 or higher it's working without NppExport plugin. Just make right-click on the selected text -> Plugin commands -> Copy Text with Syntax Highlighting. – Ivan Kochurkin Aug 07 '16 at 19:00
-
2Current version of Notepad++ already comes with this plugin :) – fabriciorissetto Nov 27 '16 at 17:53
-
1
-
Direct copy to PowerPoint did not worked well, I paste the code to Word and copy it from word to PowerPoint – Alireza Fattahi Aug 28 '23 at 04:45
Pygments can format almost every format to rtf:
pygmentize -f rtf -o code.rtf code.py
- 451
- 5
- 9
-
3
-
6Same idea, straight to the OS X clipboard `pygmentize -f rtf code.py | pbcopy`. – Christian Long Mar 14 '16 at 14:28
-
Thanks for this. I got very favorable results with `pygmentize -O style=paraiso-dark -f rtf -l aspx-cs Index.cshtml | pbcopy` for syntax highlighting of a Razor view for use in a presentation. – Asbjørn Ulsberg Jun 20 '19 at 20:42
-
Adding to what @ChristianLong suggested, but for Linux: `pygmentize -f rtf code.py | xclip -sel clip`. Note that you will probably have to install xclip. – Matthew Cole Nov 19 '19 at 23:16
If the source code does not need to be copied and pasted out of the presentation, a quick and dirty solution could be to simply take screenshots of the source code.
- 1,381
- 8
- 11
-
12
-
-
4Doing so can increase the size of the presentation file significantly. – Rufflewind Nov 10 '16 at 17:39
-
1This also has the drawback that once screenshot, it is no longer possible to resize the column width. This becomes a problem if you try to fit a 80 column printout into a 2x1 horizontal slide layout, a 132 column source into a 1x2 vertical layout, for example. The `pygmentize` answer above doesn't suffer from this. – Matthew Cole Nov 19 '19 at 22:55
- Click on Insert → Object → OpenDocument Text
- Paste on opened panel
- Click outside.
Note: Copying from Notepad++ will preserve colors and styling.
- 14,638
- 9
- 54
- 58
- 131
- 3
-
1Doesn't work for power point 2010. I copied text from Notepad++ to Power point presentation but it looses colors and styling. – ART Jan 04 '16 at 05:11
-
2If I use NPPExport pluging and use "copy RTF to clipboard" and then paste it works. – ART Jan 04 '16 at 05:13
Copy the code and first paste that code into Microsoft word
Then do the formatting if necessary and then copy from word and paste back to powerpoint by right clicking and choosing use destination theme
- 121
- 3
-
Either way, what does “Then do the formatting if necessary” mean? – Scott - Слава Україні Apr 26 '17 at 19:10
-
It means if you want to do some changes of your own like aligning or indentation of code – selftaught91 Apr 26 '17 at 19:17
-
This was the only way that I could copy and paste code from IntelliJ (a special program used for writing code) – robert Nov 14 '19 at 04:15
Here's another approach:
- Find an online source code syntax highlighting service.
- Paste the code to highlight into the web site.
- Copy the highlighted version.
- Create a new Word document.
- Paste the code into Word (note the background colours may be lost).
- Copy the code from Word.
- Create a new text area in PowerPoint.
- Click the Home menu option.
- Open Paste on the ribbon.
- Select Keep source formatting.
- Optionally, change the text area background colour to taste.
Adjust the font using Inconsolata or other monospace font.
- 3,168
- 5
- 32
- 37
Using Notepad++ and Npp Export works great, but your text will end up with a white background.
To remove it, paste first the text in word with the "preserve source formatting" option. Then, select the text and in Home > Font, remove the background with the Text Highlight Color option.
Then, copy again the text from word, and paste it in powerpoint with the "preserve source formatting" option.
- 11
- 1
Online syntax highlighter like TextMate seems good as well, http://markup.su/highlighter/
But after pasting into PowerPoint presentation new lines and line spacing is lost, so we can take a screen shot of the preview and paste it in our PowerPoint presentation
-
Pasting into ppt does not quite work here on Windows 10: The new lines are not pasted. – koppor Nov 24 '15 at 15:22
I've had no success pasting into Powerpoint 2010 on Windows.
However, pasting from Eclipse into Word 2010 works.
You can then save this formatted text as an RTF file, then embed the RTF into a Powerpoint 2010 slide using Insert Object (and optionally select 'link' so you can edit and update the text in Word).
- 196
- 2
- 5
Pasting from Eclipse should retain formatting if the app supports it. I know Word does... not sure about PPT.
- 7,195
- 1
- 27
- 31
-
1Works from Eclipse Juno to Word 2010, but not to Powerpoint 2010 - it loses the colours and converts some of them to bold text – DNA Sep 04 '13 at 17:21

