Copy syntax-coloured code block as rtf in intellij

2019-01-17 10:38发布

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

5条回答
唯我独甜
2楼-- · 2019-01-17 10:53

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

查看更多
戒情不戒烟
3楼-- · 2019-01-17 10:58

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).
查看更多
家丑人穷心不美
4楼-- · 2019-01-17 11:03

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.

查看更多
Melony?
5楼-- · 2019-01-17 11:04

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

enter image description here

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

查看更多
smile是对你的礼貌
6楼-- · 2019-01-17 11:06
  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.
查看更多
登录 后发表回答