开发者

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

开发者 https://www.devze.com 2023-02-08 01:31 出处:网络
Is there a simple way to copy syntax-coloured code开发者_如何转开发 block as rtf in intellij IDEA?UPDATE: there is now a new plug-in for this: \'Copy\' on steroids that is maintained by JetBrains.

Is there a simple way to copy syntax-coloured code开发者_如何转开发 block as rtf in intellij IDEA?


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).


IntelliJ IDEA 15

By default, you can copy rich text from IntelliJ to Microsoft Word (for example).

This feature can be found in File > Settings... > Editor > General > Rich-text copy > Copy as rich text by default

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

You can also change the color scheme only for the copy-paste operation (your current scheme won't be affected).


  1. Go to https://gist.github.com/
  2. Copy code from IntelliJ to the new private gist;
  3. Save it, copy colorful code from the browser to wherever you want;
  4. Delete the gist.


Use external tool notepad++ 1) copy code snippet to notepad++ 2) apply syntax highlighting 3) copy with nppexport plugin to clipboard as rtf


If you're on a mac and like TextMate, here's a great way to copy styled code from TextMate: https://github.com/bblimke/copy-with-style-tmbundle

It's not as convenient as doing it directly from IntelliJ, but it's a bit more convenient than using gist or pastebin. Also, unlike the Copy as HTML Plugin for IntelliJ, this solution actually works at the time of this writing.

0

精彩评论

暂无评论...
验证码 换一张
取 消