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

徘徊边缘 提交于 2019-12-17 22:45:48

问题


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:


  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.



回答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.



来源:https://stackoverflow.com/questions/4883432/copy-syntax-coloured-code-block-as-rtf-in-intelliji-idea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!