How to format characters in a custom eclipse editor plugin - eclipse-plugin

I'm writing a custom editor plugin in Eclipse and I'm trying to figure out how to format certain character sequences with symbols. So in the editor view typing -> would be replaced with →. I don't want to modify the underlying document content, just how the characters are displayed. The TextAttribute class only allows me to change the style of the text, not what is actually displayed.

You would probably have to copy all of the Eclipse classes having to do with the editor into your own project so you could modify the method(s) that displays characters on the screen.

Related

Adding Editor Style in IntelliJ WebStorm

I recently started working on an Angular project in WebStorm and would like to change the editor style to add more spaces on formatting code with CTRL + ALT + L.
Currently, when I format my code, all spaces are gone. Here are some places,
But I need to have a one indentation between the {} or method parenthesis. What I expect is as below:
Please help me create this style for Angular / TypeScript development editor. Thanks in advance.
For the ones out there trying to add formatting to their code, here I will post my own answer. You can set custom spacing and styling into your code in intellij IDEs.
Settings -> Editor -> Code Style
Navigate here and you can define custom styling and spacing specific to your programming language and can even export the created styles as an XML file.

What IntelliJ plugin contributes the "View as JSON" option?

I used to see an option when right-clicking on JSON text in the Output console, View as JSON, which would open the line of text in a JSON edit tab. A while ago I disabled some plugins I don't use and now that option is gone.
Which plugin provides "View as JSON?"
Most likely it's the Show as... plugin
A small plugin to display formatted data out of the debugger.
Uses IntelliJ's build-in formatting capabilities. No more need to
copy values from debugger to a file to format them there. Following
formats are supported:
Xml
JSON
Base64 encoded JSON
Base64 encoded text
Usage: While debugging, a new context menu item ("Show as") is
added to every variable, allowing you to display the value of this
variable formatted. The context menu item is available in debugger ->
variables, debugger -> watches and when evaluating expressions.
The "Show as" plugin didn't work for me.
Alternatively, you can create "Show Type Renderers" in the IntelliJ preferences as follows:
Uncheck On-demand if you want to render your object as JSON without clicking "View".

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.

intellij messes up with tabs in non-program files

so i just spent some time fussing over why my String.split call in scala failed - i was trying to split on a tab.
Problem wasn't what i was doing, but rather the fact that intelliJ changes tabs to spaces. Fair enough, but can i tell intelliJ to not do that for some files - like say random text files I might be using for test/learning purposes?
First, I would turn on Settings > Editor > Appearance > Show whitespaces, that way you're SURE what white space characters are there.
Next, under Settings > Code Style > General there should be a Use tab character check box. This says "use tabs for anything that's not Java, Scala, HTML, etc.". Just make sure Java, Scala*, etc. Use tab character setting is set to what you want.
Unfortunately, I don't know of any way to be more fine grained with what file types do and do not use tabs vs. spaces.
*I'm assuming the IntelliJ Scala plugin adds a tab in Settings > Code Style.

Copy syntax-coloured code block as rtf in intelliji 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.