Is there a simple way to copy syntax-coloured code block as rtf in intellij IDEA?
问题:
回答1:
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).
回答2:
- Go to https://gist.github.com/
- Copy code from IntelliJ to the new private gist;
- Save it, copy colorful code from the browser to wherever you want;
- Delete the gist.
回答3:
Use external tool notepad++ 1) copy code snippet to notepad++ 2) apply syntax highlighting 3) copy with nppexport plugin to clipboard as rtf
回答4:
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
You can also change the color scheme only for the copy-paste operation (your current scheme won't be affected).
回答5:
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.