Reset formatting of code to default - netbeans

I am using NetBeans for my C++ development.
Previously there was nice formatting of code but it has changed.
This is the format that I want
This is the format that I am getting
Note the two closing braces in one line after connection line and also the closing braces after semicolon in else statement.

if you press crtl + a then right click, you will find a "format" option. I hope this helped!

Related

Visual Code IDE curly brace formatting

I am trying some TypeScript stuff in Visual Studio Code Editor.
When the intelligence generates a class or function, the curly brace is opening in the same line. I don't prefer that style. I needed the curly brace to be started on the new line always. Can you tell me how to make that and which settings to be turned on?
Thank you in advance
Although I do not recommend this settings you can add the following entries to your settings.json to achieve that behavior:
"typescript.format.placeOpenBraceOnNewLineForControlBlocks": true,
"typescript.format.placeOpenBraceOnNewLineForFunctions": true
Now every time you hit Shift + Alt + F to format your code the braces will be set on a new line.

highlight expressions on netbeans

I want to know if there is a way to highlight the full content in an expression like if, while, etc.
I have to work in a code that is bad indented where expressions can cover over 1000 lines and I can't format it.
for exemple :
if ($somethingTrue) {
while ($somethingHappen) {
// 500 lines...
} }
if ($someCondition) {
}
look, it's very hard to see the end of the first if and what it cover...
Does someone know if there is a native feature or plugin on netbeans that do this job ?
Thanks !
You don't need any plugin/external jar file for achieving the same. Whichever expression you want to check the body of, just click on the opening brace after that expression and NetBeans will automatically show you the closing brace for that expression.
Basically, Netbeans shows the ending brace for a corresponding starting brace entry---for each of if-statements,loop-statements,method declarations,etc.
In the shown figure, see my if-statement starting with yellow brace(cursor blinking there), and the corresponding ending brace for the if-statement.
EDIT :-
You also can also have a brand new-code fold,just by typing fcom, and hitting (Tab) button on KeyBoard. And, then put whatever block you want inside it and done. Expand whenever you wish and collapse whenever you want.
Check the position of my mouse-pointer which shows the current block of if-statement. You can expand and collapse as per your wish. And, also you can have several of them for each of your expression-tree.

Netbeans Auto-Indentation and Curly Braces }{

Is it possible to set up the NetBeans editor to automatically unindent closing curly braces?
I want this:
if (something){
do thing one;
do thing two;
}
Netbeans gives me this:
if (something){
do thing one;
do thing two;
}
and then I have to delete the four preceding spaces which is annoying. It would be nice if it would automatically unindent after typing the closing brace.
Any ideas?
Is it possible to do this with a macro?
I ended up asking this on the netbeans forums and it turns out that it's a bug. If you have 'auto-insert braces' turned off, the braces won't align automatically, but everything works fine with 'auto-insert braces' turned on.
NetBeans, as any other IDE, formats automatically the code (by default).
So, when you insert the closing } it will remove the unnecessary spaces automatically.
Anyway, you can select Source → Format or press Alt+Shift+F to re-format the code.

NetBeans curly braces auto-closing

In the last time I often initialize arrays in this form :
int[] test = new int[]{1,2,3};
When I type '[', NetBeans immediately put the closing brace.
The question is - which is the macro to do the same job with curly braces ?
Select from menu Tools > Options, select Editor in toolbar, go for Code Completion tab.
You will see that Insert Closing Brackets Automatically is already automatically checked by default.
There was a guy, who asked an analogical question a while ago. There was no helpful answer. I guess that means that we should look for that in future versions.
I looked for solution too, for NetBeans 8.5 check answer, https://stackoverflow.com/a/38338967/7162006, in same window is option: Completition Selectors For Java add: {, autocomplete by hiting enter in editor. (classically)
This macro work to me:
Shortcut: Shift + {
Macro code: "}" caret-backward

Remove blank line in Eclipse

How can I remove lines that only contain spaces when using Eclipse Find/Replace prompt. I checked the "Regular Expression" check box, and tried the following, neither of which worked.
^[:space:]*$
and
^\s*$
Find: ^\s*\n
Replace with: (empty)
sry this might be an different answer but you can set the number of blank lines you wish to have after fields, methods and blocks in the formatting dialog of the eclipse preferences. then you can hit ctrl-shift-f to automatically format your code depending on your custom definitions.
have fun!
I was suprised that for XML files edited with Eclipse there is a good solution:
Select the checkbox value named 'Clear all blank lines' in Formatting panel
Window->Preferences->XML->XML Files-> Editor
Save and use the "Ctrl+Shift+F' shortcut
The blank lines will dissappear!
for the find/replace operation, "\n\r\s" regex will work on windows, for unix based system, "\n\s" can be used
as already suggested, you can format your code by Ctl+Shift+F
for manual work, locate a blank line and press Ctl+D (Cmd+D on Mac) <- gives u satisfaction of killing the line with your own bare hands :)
cheer!
This one worked for me for years:
Replace this: [\t ]+$
With nothing
Hope this helps!
Many thanks to lamamac.
In genereal, when you want to do search replace with regular expressions in eclipse the $ sign doesn't work as it should.
Use '\s*\n' instead of '$'
As already suggested, regular expression and replacement is the solution, but such response would have been saving some minutes to me:
click on ctrl+f
use this replacement: