Automatic closing of curly braces loops and other things for Java code
Answered
Hello. Please either disable automatic insertion of closing curly braces, or allow adding a closing curly brace only if there are more opening brackets, otherwise do not add anything. Thanks.
Please sign in to leave a comment.
Settings (Preferences on macOS) | Editor | General | Smart Keys | Insert paired brackets (), [], {}, <>.
for (;;) { press enter
will appear }
but if we already have }
it breaks the code
If you already have }, IDE will not add another one:
Strangely, it worked cleanly now. The next time it haunts me, I'll write.
Please share the project/code/steps via https://uploads.jetbrains.com.
I tried it again with the Tab button, and now there are as many brackets as I need. Maybe this is due to a weak PC?
Upload id: 2023_02_19_UTKkKQyzvp27XLkFK8HZpg (file: Project.rar)
I tried with Space, Enter and Tab, can't reproduce. Completion inserts the correct anonymous class with the right brackets. PC hardware should not affect the completion behavior.
See if you can reproduce it with the default settings: File | Manage IDE Settings | Restore Default Settings...: https://i.imgur.com/kbrkC7w.png.
Mouse can it too) Perhaps it depends on the number of processor threads. The output thread can overtake the parenthesis counting thread, this is figurative.
> The output thread can overtake the parenthesis counting thread, this is figurative.
It's unrelated.
See https://youtrack.jetbrains.com/issue/IDEA-70016/error-mixing-stdout-stderr.
There is a registry option (Help | Find Action | Registry):
Merge processes standard streams (error and output). This makes it easier to correlate error messages with the corresponding output. However, as a result, it won't be possible to distinguish between stdout and stderr. This option is supported only for certain run/debug configurations. If it is not supported for your run/debug configuration, please submit a request in issue tracker.
All these parenthesis events don't happen that often, I'm not too worried about it. Thanks.
If I open the curly brace, then put the cursor on the commented line, press Enter, and no miracle will happen) And it would be nice to add the ability to search in the console window.
It doesn't work like that. Enter needs to be pressed right after opening the curly bracket in order for its closing twin to appear.
If you want to put brackets around an existing comment or code fragment, you can put the cursor on the commented line or select the fragment, press Ctrl+Alt+T and then select the construct that you need your code to be wrapped into. For curly brackets, the shortcut is "A".
Search in the Run console window is already implemented. Just hit Ctrl+F to bring up the search pane.
It doesn't work like that, but if you put a closing curly brace behind the commented line and press Enter before it, then the curly brace will be commented out in a new line)