Is there a plugin to tell IntelliJ not to format a particular block when I use auto format? - intellij-idea

My question is a duplicate of: How to turn off the Eclipse code formatter for certain sections of Java code? but for IntelliJ.
Does a similar feature exist for IntelliJ?

Yes, and It works the same way with:
#formatter:off
and
#formatter:on
Navigate to:
Settings > Editor > Code Style > Formatter control

Related

Intellij Code completion in (s)css annoying

I am developing in IntelliJ IDEA mainly scss and js. When I want to type
th, td {
some style
}
Intellij autocompletes td to "text-decoration:;" (and th to text-height) which is highly annoying. I have checked all my settings and plugins and am currently lost. I have the setting "Code Completion > Insert selected suggestion" turned off under "Show suggestions as you type".
My enabled custom plugins are Emmet Everywhere, Save Actions and Vue.js. Disabling those does not solve anything.
I would honestly love to enable autocompletion per language/per extension and not as a global setting.
Any thoughts?
As #lena pointed out, Settings > Live templates > By default expand with was set on space which caused this behaviour. With so many options it can sometimes be hard to find unusual settings.

Jetbrains Plugin Custom TextEditor Rendering

How does one go about extending the jetbrains texteditor in a plugin to replace the text/characters/tokens with images/sprites?
This is not possible in the current version of IntelliJ IDEA (2016.3). The only possibility is to use the EditorInlay API to insert custom-drawn fragments between characters in the editor.

How do I turn on syntax highlighting for StringTemplate templates (*.st) in intellij?

I have a string template file (.st) in IntelliJ that I would like to see syntax highlighting on. How can I turn this on? I can't seem to find it anywhere.
The best solution is to use HTML syntax for *.st files. You can set this in Preference > File types > HTML.
Short answer is - you can't.
Someone must first implement a syntax highlighter plugin for the format.
The StringTemplate author, Terrence Parr, has begun work on such a plugin for String Template 4 but it does not support the older .st file format.
I tried the plugin. Even on .stg files it is not ideal if you use a dark editor theme.

How to add shortcuts ("templates") to eclipse properties through my plugin?

I'm developing a plugin for visualization of objects by calling Doo.dle(Object o).
Now I'd like to automatically define a shortcut like sysout for System.out.println(), e.g. doodle.
I already know how to do it by hand:
Window > Preferences > Java > Editor > Templates
Is there an extension point or something similar to do this automatically with my plugin?
I managed to do it on my own:
I had to define a javaCompletionProposalComputer extension and implement an ICompletionProposal.
It's not exactly what I intended, but it's working too.
Update:
I finally found it out:
The key is to define an extension for org.eclipse.ui.editors.templates. Patterns etc. can be cheated off predifined templates in eclipse properties (see question).

How to disable code formatting for some part of the code using comments?

I'd like to selectively disable the IntelliJ IDEA code formatter for a portion of code just like I can in Eclipse. Does IntelliJ support this feature, and if so, how do I use it?
Since version 13 it's possible to wrap the code with
// #formatter:off
...
// #formatter:on
IntelliJ IDEA v.2018+:
File > Settings > Editor > Code Style
IntelliJ IDEA v.2016+:
Preferences > Editor > Code Style
IntelliJ IDEA v.14+:
Preferences > Editor > Code Style > Formatter Control
You can change the formatter control markers, as long as they're in comments.
Ensure formatter markers in comments are enabled, as shown in the following figure:
Note for Carlos' answer of #formatter:off and #formatter:on to work, you may need to enable the preference first:
Discovered via How to config intellij-idea not format some part of the code?
IDEA-56995 Disabled code formatting per region using comments
In xml files, use:
<!-- #formatter:off -->
<!-- #formatter:on -->
Obsolete answer from 2010:
No, it's not possible right now, I've submitted a new issue which you can track.
As a temporary solution you can use external formatter plug-in for IDEA which can utilize Eclipse code formatter (I didn't check whether this particular option is supported).
It's currently not possible to exclude entire files (like regression test data xmls) from formatting. See https://youtrack.jetbrains.com/issue/IDEA-167112