All Blog Posts  |  Next Post  |  Previous Post

Color your Delphi source code on the clipboard


Tuesday, April 12, 2011

When writing documentation for your projects, components etc..., source code snippets are indispensable to clarify things. Sadly, when performing a "Copy to clipboard" from the Delphi IDE code editor, this is copied to the Windows clipboard as plain text. Pasting this into MS Word, a CMS or in another webpage editing tool leaves us with dull single-colored text. For years, we then tried to resort to tools like an MS Word macro to reapply syntax coloring, a Javascript library that performs syntax coloring directly on the web page or something like YAPP.
Now, wouldn't is be much faster and more convenient if we could, just like in Visual Studio, copy a snippet of code to the clipboard and just past it immediately in MS Word or a web page with syntax coloring applied? We've just released a free plugin for Delphi 2010 or Delphi XE that allows you to do just that.

After installing this IDE plugin, you have two new items in the IDE main Edit menu as well as the editor context menu: Copy as RTF and Copy as HTML. Simply select some source code in the editor and choose "Copy as RTF" and paste in MS Word and you immediately have a syntax colored code snippet in the MS Word document. Or choose "Copy as HTML" and paste in a web document with all Delphi code coloring applied.
Enjoy this free plugin!

Bruno Fierens


This blog post has received 13 comments.

1. Tuesday, April 12, 2011 at 7:25:17 AM

I cannot get the menuitems to appear. The package seems to be disabled in the registry (Underscore in front of data-value in Known Packages), but removing the underscores doesn''t help either. Any ideas?

Fredrik Loftheim

2. Tuesday, April 12, 2011 at 10:12:17 AM

Delphi XE Update 1, Windows 7.

Installation install the .bpl incorrectly, and it fails to load.
Manually installing the .bpl appear to work, and both Copy RTF/HTML appears in the menu. However - no content is copied to the clipboard when activated - but the clipboard is cleared.

Lars Fosdal

3. Tuesday, April 12, 2011 at 10:23:41 AM

Didn''t work for me either.

Steve Summers

4. Tuesday, April 12, 2011 at 11:06:22 AM

Do you make sure to FIRST select text in the editor? It only copies the selected source code to the clipboard.

Bruno Fierens

5. Tuesday, April 12, 2011 at 1:41:22 PM

You can also try the free GExperts. It has a Source Export expert that does the same thing:

Drennan Allen

6. Tuesday, April 12, 2011 at 3:37:50 PM

Didn''''t work for me either.
delphi 2010 vista 64 bit

Allen Rotton

7. Tuesday, April 12, 2011 at 4:40:52 PM

Can you describe "didn''t work"?

Bruno Fierens

8. Tuesday, April 12, 2011 at 5:09:22 PM

@Bruno: There seems to be some issue with the installer which registers the bpl into the registry with a wrong name (typo i guess).
After installation, starting Delphi XE and getting the "so and so bpl not found, do you want to ... etc" dialog i checked the registry and changed the entry to the correct name.


9. Tuesday, April 12, 2011 at 5:12:30 PM

There also seems to be some issue with the clipboard format.
I tried copying with both options and pasting into notepad and it did not do anything. Then I opened MS Word 2007 and pasted it there and it worked.


10. Tuesday, April 12, 2011 at 5:20:30 PM

That is by design, the app retrieving data from the clipboard should support a rich text or html text clipboard format and Notepad does not.

Bruno Fierens

11. Wednesday, April 13, 2011 at 3:07:18 AM

There was a small glitch in the installer. Is fixed now.

Bruno Fierens

12. Thursday, April 14, 2011 at 3:17:35 AM

You need to register the HTML and RTF as cf_Text in addition to cf_HTML and cf_RTF. That way, the HTML and RTF can be pasted in to a plain text editor as well. This is necessary if you edit HTML files with RAD Studio.

Lars Fosdal

13. Thursday, July 14, 2016 at 8:19:10 PM

This is exactly what I was looking for. So exhausted I was using Notepad++ for the same. This is going to change the world of Delphi help and documentation and that is my mission.


Add a new comment:
  You will receive a confirmation mail with a link to validate your comment, so please use a valid email address.

All fields are required.

All Blog Posts  |  Next Post  |  Previous Post