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

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
You can also change the color scheme only for the copy-paste operation (your current scheme won't be affected).

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.

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.

Related

How to copy a link from markdown preview? Mouse right-click, Ctrl-C or Ctrl-Ins don't work. (copy doesn't work for any text in the preview?)

A markdown file is opened under IntelliJ and from its preview if I do a left click on a link, it will follow it and open it the default browser.
But for my current work, it's not what I'm willing to do.
I need to copy its underlying URL to open it on another browser of my choice, that isn't the default one.
But whatever I attempt:
Right-clicking on the link with the mouse
Attempt to copy it by selecting its text and doing Ctrl-C or Ctrl-Ins
the underlying URL of that link isn't copied and I cannot paste it.
Of course, I can enter the .md definition and select that URL part that is between parenthesis, but it's not convenient.
* [COG 2021 : https://www.insee.fr/fr/information/5057840](https://www.insee.fr/fr/information/5057840)
And furthermore, I cannot copy any text content from that preview...
Is there a way to make IntelliJ preview window of a markdown file gaining the expected ability of copying to the clipboard ?
Use markdown editor for this. For example Typora.

File named "auth_actions.dart" won't be highlighted in Intellij-idea

I created a file named "auth_actions.dart" in a dart project(either angular or not). The file content would have text colour being plain white, without any highlighted.
If I rename it to "auth_action.dart" or "auth_actionss.dart", the highlight will come back.
I did some experiments even from some random projects downloaded from github, all of them had this issue.
Anyone know how to fix it? Does anyone see the same issue using the name "auth_actions.dart"?
I assume you accidentally added the file to
Preferences > Editor > File Types > Recognized File Types > Text
Remove it from Registered Patterns to get hightlighting again.
You could accidentally mark it as plain text (the option is in the right-click menu). In this case, the option to mark it back as a Dart file is also in the context menu.

How to auto indent in WebStorm

I need to indent multiple files in WebStorm. Its option "Auto-indent" in the Code menu only indents current line.
How do I use it on multiple files like I can use "Reformat Code"?
Select the folder you want to reformat the code for in the Project tool window. Then select Code | Reformat Code
This page explains it. https://www.jetbrains.com/help/idea/2016.1/reformatting-source-code.html

How to get HTML-formatted code from clipboard? [duplicate]

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
You can also change the color scheme only for the copy-paste operation (your current scheme won't be affected).
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.
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.

How to Pretty print VBA code?

How do you copy VBA code into a Word document and retain the VBA editor color scheme?
You can use Notepad++ to accomplish this in three ways. Just so you know, Notepad++ is a more advanced version of Notepad, which supports syntax highlighting of different code files "out of the box" - Visual Basic included!
Download & install it, fire it up, and load up your VBA code. You should automatically see it beautifully coloured (if not, because the file extension is something other than .vb, go to Language -> VB or Language -> V -> VB).
If you need to change any of the colours, you can easily do so - just go to Settings -> Styler Configurator. From that menu, you can change the various highlighting and font options, to suit your needs - although the default usually suffices for most.
Then, go to Plugins -> NppExport. From there, you have three options you can consider:
Directly print from Notepad++
Copy all formats to clipboard
Export to RTF
Export to HTML
The first is self explanatory. The second one - "Copy all formats to clipboard" - will copy the entire file with the highlighted syntax to the clipboard. Once you click it, then open Microsoft Word or your other favourite document editor, and just hit paste! You should see the beautifully syntax-highlighted code. If something goes wrong, then you can try one of the other options (export to RTF/HTML), although I've never had a problem with the clipboard method.
There are two programs on cnet downloads, which are free to try. In case you did not try them, here are the links:
VB-VBA Code Formatter & Printer 2.2
VBAcodePrint 6.13.110
Smart Indenter could be what you're looking for? You'd load the result into Notepad++, set language to VB and save as .rtf/.doc (or print to file, can't remember off the top of my head).
For a more modern approach, Sublime Text users can install ExportHTML from Package Control. This has the added benefit of being able to include the line numbers, and changing the code coloration.
HTML files can be opened directly within Word.
Highlight supports a wide range of Operating Systems and 150+ languages including Visual Basic, although I'm not sure about VBA.
I would recommend this one: planetB
It works well with Internet Explorer (didn't work wit Firefox for me, not sure abt Chrome).
Plus it's online, so no need to install anything (the case of Company/University PC's)
Regards
Wheeliam
The following works with Visual Studio Code:
Start VS Code.
New file.
Copy & Paste the VBA code into the VS Code window.
In the lower right-hand corner, click on "Plain Text" and select "Visual Basic" instead. Note that the code is now syntax-highlighted.
Copy & Paste the formatted code into Word.