Rider automatically places attributes on the same line as the property [duplicate] - rider

I prefer my code to be more compact but JetBrains Rider (or any IntelliJ based editor) automatically formats it like this:
void Start()
{
}
How can I change it to the following by default?
void Start() {
}

You should not configure this thing manually in settings, just allow Rider to "learn" from your code.
Format code block as you like
Select desired code block and invoke Reformat and cleanup... -> Detect code style settings... from alt+enter menu:
Observe changes which Rider detects:
Save settings for all solutions on this machine, or just for the specific (current) solution. There are other options also:
Now your IDE is configured to format code exactly you want :)
P.S. This thing works in JetBrains Rider and R# tools, do not know about other IDEs, probably there you have to find the same settings manually.

Related

How to stop reformatting of intelliJ after save

This is a simple question that I can't find an answer. I'm using IntelliJ for Java practice.
I have blocks of code that are just a single line, followed by an end brace, like this,
public void example(){
System.out.println("Some string");
}
Edit: After saving and closing the app, then reopen the project, IntelliJ reformats this as
public void example(){ System.out.println("Some string"); }
How do I stop IntelliJ from doing this? It becomes a hassle when I need to add more things into the block, I need to click it to expand the block. Thank you!
It is not reformat, it is a folding feature. Please disable the Settings (Preferences on macOS) | Editor | General | Code Folding | One-line methods option.
Since this is not IntelliJ's standard behaviour, I assume you might have Save Actions plugin installed.
If this is the case, check its options (Settings -> Save Actions -> Formatting actions).

How to make auto completion in WebStorm (*.js) and IntelliJ (*.go) work the same

In WebStorm I can type something like
document.gEBI
press tab key, and it'll autocomplete to
document.getElementById()
But when I do the similar thing in IntelliJ
fmt.Prl
Auto completion doesn't work (the desired result fmt.Println()) at all, it works only if all the letters match strictly in order.
Is it possible to enable this functionality in IntelliJ? I've imported all the settings from WebStorm.
These Tab key shortcuts aren't part of the auto-complete system the Jetbrains use for all their IDEs as LazyOne says, they are actually part of the template-invocation system.
The auto-complete functionality is built into the shortcut: Ctrl+Space.
I suggest looking up the template invocation for .Println() in the settings, Jetbrains documentation, or raising a ticket with Jetbrains on YouTrack for clearer documenation/control over template-invocation.

Intellij adding extra line in new blocks

When I'm writing code in Intellij, I often create new blocks by typing these types of sequences:
if (test) {
Typing that open curly brace causes Intellij to automatically insert a closing brace and move the cursor between the two braces:
if (test) {|}
At this point, I simply press Enter and get a nicely formatted block with the cursor right where it should be:
if (test) {
|
}
However, today Intellij is adding an extra line to the block, like this:
if (test) {
|
}
I've looked all over the project and IDE settings, but I'm not sure what to change. FYI, it's happening in various file types (.java, .js, .css) across different types of projects (Spring/Java, Node/Express). Anyone know how to fix this little annoyance?
Just got this error myself. Weirdly enough, for me it turned out to be the AWS Toolkit plugin.
If you have the same problem, it is most likely something with one of your other plugins if not the one mentioned above. I went through tons of IDE settings, and believe me, I wouldn't wish that upon anyone ;)
As of 5MAR2015 the solution is to disable the Gauge plugin. Credit for this goes to #KaPaHgaIII

Allman-Style in Intelliji

I was wondering how I might configure Intelliji IDEA to automatically make my code look like:
public void Something()
{
// something
}
rather than:
public void Something() {
// something
}
I believe it is called the "Allman" style. Intelliji comes out of box using the "K&R" (I think?) style, however.
go to project settings. configure code style formatting.
To do Allman for Java (newbie-ish version) go to File/Settings/Editor/Code Style/Java. Next select the Wrapping and Braces tab and expand Braces placement. Now you must click 'End of line' for all three choices and select 'Next line' for each in the box that appears. Then click apply and OK.
I know this question is already answered, but to save people from actually modifying the settings.
Here is the AllmanIndent.xml download the .zip file.
After you download and extract the zip do the following steps:
From IntelliJ go to File->Settings->Editor->Code-Style and click the gear icon by the "Scheme" and then click on "Import Scheme -> IntelliJ code style XML" and then choose the extracted .xml file.
After this import, you can press Ctrl+Alt+L to auto-indent code.

Change text color of commented program code?

I'm looking for a simple feature or work-around that can highlight commented program code as opposed to technical notes. Is there such a feature or other way to do it?
I want this to appear in light gray, as normal:
//avoids a ClassCastException. See bugfix #123
I want this to appear in orange so that it can safely be removed (the history for which would be under version control):
//public static void method() {
//}
I searched SO but no luck.
There is no such feature in IntelliJ Idea. Fortunately, there is even better way to avoid commented-out sections of code in your project.
The best option is to use Static Code Analysis tool such as Sonar - it has a rule which detects commented-out lines of code and reports the issue to you. After running such tool you can be certain you have no commented-out dead code in your project.
See the post about Commented-out code eradication with Sonar.