Copy syntax-coloured code block as rtf in intelliji IDEA?

qwazer picture qwazer · Feb 3, 2011 · Viewed 11.5k times · Source

Is there a simple way to copy syntax-coloured code block as rtf in intellij IDEA?

Answer

CrazyCoder picture CrazyCoder · Feb 3, 2011

UPDATE: there is now a new plug-in for this: 'Copy' on steroids that is maintained by JetBrains.


There is no way to copy colored code block from IDEA directly.

A workaround is to use File | Export to HTML, then open HTML in a browser, then copy from the browser window and paste into Wordpad or MS Word.

Another and more faster way is to install the Copy as HTML plug-in in Settings | Plugins:

Copies a snippet of code as html

  • Adds menu items "Copy as HTML" to main menu and editor popup. Will copy the current selection or the complete editor buffer. Currently only works if focus is in editor (for example won't work in project tree).
  • Preserves more formatting than the built-in HTML export.
  • HTML is only a snippet (without html and body tags) meant to be inserted into a complete HTML document.
  • Currently HTML format is fixed and uses CSS a lot.
  • Options: unindent, add border, padding, line numbers, tabs to spaces conversion, include editor's warning and error highlighting (see IDE Settings -> Copy as HTML).
  • Reuses the editor "Show Line Numbers" setting (see Idea's "View" menu).