Copy/Paste Syntax Highlighting in RTF/HTML
Many of us working with source code on a daily basis frequently have a need to share a small sample (or more) of that source code with others whether it’s via email, in a Word doc, or as HTML in part of a blog post or tutorial web page. With UltraEdit, you can add beauty and visual order to your sample code by pasting it with its syntax highlighting as RTF or HTML source!
Copy highlighting as RTF (for Word, Outlook, and other rich text editors)
If you want to quickly paste a snippet of source code into an email or a Word Doc with its syntax highlighting intact, you can use UltraEdit’s “RTF to Clipboard” command to send it to the clipboard and then paste it into any application which supports rich text format (RTF) such as Outlook, Word, Thunderbird, etc.
Select the portion of code you’d like to copy, then go the Edit menu and select Copy Special -> Copy as RTF. Your code, complete with syntax highlighting colors, is now stored on the clipboard.
Simply press Ctrl + V in your other application to paste the code with syntax highlighting. It’s that simple!
Copy highlighting as HTML (pasting as HTML source)
When the need arises to add sample code to a web page – whether it be for a blog post, tutorial, forum post, or something else – UltraEdit can format and provide the HTML and CSS markup you need to make your rendered sample code look exactly as it does within UltraEdit!
To copy your code with highlighting, select the portion of code you’re copying, then go the Edit menu -> Copy Special ->. There are two options here:
- Copy as HTML Document
- Copy as HTML
Copy as HTML Document
This option will copy the syntax highlighted source code as a well-formatted HTML document including doctype declaration, <head> tags, and all styling in CSS classes added to the head of the document. Use this option if you want to create a completely new HTML page to contain your source code.
Copy as HTML
This option will copy the syntax highlighted source code as an HTML fragment with inline CSS styles. Use this option if you want to paste your syntax highlighted source code into an existing HTML page.
You can now paste the HTML source into an HTML document or content editor to share with your readers!
You can also set key mappings for these three commands in Advanced -> Configuration -> Key Mapping. Look for the following commands: