Netbeans Auto-Indentation and Curly Braces }{ - netbeans

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.

Related

Show line of matching brace for Java in Eclipse

So, let's say I select a closing brace. I want eclipse to not only highlight the matching opening brace, I want it to show me its whole line on the top of my editor, no matter how higher up it is. I'm sure I've seen it on some other IDE, is it possible to do on Eclipse? For example, if it's a closing brace for an if statement, I want to see the opening of this if to see its condition. This could also apply to methods, loops, etc.
If not showing the whole line, I would at least like to highlight the whole line with a color that stands out, so that I can find it easier through scrolling. I know I can jump there with Ctrl+Shift+P, but it's not always practical.

Reset formatting of code to default

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!

Sublime Text 2 how to wrap selection with quotes/auto-pairing

I just switched from Textmate 2 to Sublime Text 2. I figured that typing single quotes or brackets would automatically generate a second quote or bracket with the cursor in between ("auto-pairing" is what they call it, Textmate2 does this by default) but this isn't happening.
I see that in the preferences->settings-Default there is some JSON configuration that would seem to be doing what I need but this is not the case. I haven't changed any of this default configuration.
Could someone help me add to my preferences->settings-User the configuration I need to enable auto-pairing for all the common tags, i.e., "'{[(?
Right now I'm working on a client's laptop and running Sublime Text 2 portable version from my flash drive. No additional packages installed, default settings. Everything works as expected:
When I type a single or double quote, brackets, square or curly brackets it adds a closing one and puts cursor in the middle.
When I select smth and press any of mentioned above keys it surrounds selection with pair of appropriate quotes or brackets.
Check your Settings>Default, look for this:
// Controls auto pairing of quotes, brackets etc
"auto_match_enabled": true,
It's near line 89 or so.
Not a direct answer to your question..but I have installed a few plugins in ST2 and auto-pairing works fine.
I am not sure which plugin is responsible for it. Let me know if you would like me to share the list of plugins.

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

Hungry Backspace in Eclipse?

In some editors there exist plugins implementing a feature called "hungry backspace" or "hungry delete".
If this mode is active in a text editor then one hit to the backspace key will automatically delete all whitespace chars backwards from the current cursor position up to the first non-whitespace character.
For example, this feature exists for Emacs and IntelliJ IDEA.
Does anyone know if it is also available in Eclipse?
Alt-Del is probably as close as you're going to get without writing a plugin yourself. Others have asked for this feature (coming from intelliJ) but so far it doesn't exist, or it's not published.
-Adam
CTRL-backspace is pretty close too: delete previous word:
function(); (4 spaces)
+ CTRL-BACKSPACE gives:
function
Other than that, AnyEdit plugin can convert trailing spaces into tabs (but also into "", effectively removing them)
Ctrl+Shift+Left, Backspace always works for me. works in notepad, web browsers, everywhere.
Stick to the standards :)
In SciTE, and Eclipse (3.4), Ctrl+Shift+Del with the caret after the last visible character will delete these spaces. Ie. it deletes from caret to end of line.
Actually, in SciTE I don't need to do that, since I have set it up to automatically remove these trailing spaces when saving.
Note: In Preferences > General > Keys, there is a Remove Trailing Whitespace binding (without key assignment by default) which seems to apply to File.
From eclipse Windows menu/Preferences
Search for Keys and filter to "Delete Previous Word"and Bind it to the Ctrl+Backspace