Eclipse - pressing space deletes the parenthesis before caret - java

It is hard to describe so see this GIF:
When I press space to continue typing, Eclipse Java editor decides to delete the second half of a parenthesis pair. I can press ESC to prevent this, but it is annoying.
I must have missed/tweaked some settings without knowing it, because in my working station, same as in my home, I am with Eclipse Mars 2 and I had never seen this.
It also happens if I press ; to end the line, and there is a parenthesis before the ;.
What should I change in Preference to stop it?

This is is a overtype mode in eclipse.
To disable it, press the Insert/Ins key on your keyboard and let me know if it helps.

Related

Java - netbeans - Undo / Redo Code for a notepadGUI

I’m making a notepad app as a Beginner project on NetBeans, in the edit menu, I’m looking To code a Undo Button and also a Redo Button for the last actions performed? For example, if I want to undo a paste or Cut and be able to jump back a few actions to a previous state
For this there are a few possible ways of tackling the problem.
One way, possibly the way I would do it, is store the contents of the notepad after every space key. This would allow you to press the undo button and set the text to the text before the last word was entered. For redo you could save the contents when backspace is pressed and restore it that way.
To implement this I would use an array list which is appended to with the current contents of the notepad (as a String), whenever space is pressed and/or whenever backspace is pressed and use the undo and redo buttons to cycle through the ArrayList.
I can't really give a much more detailed response as I don't know the entirety of your situation.

How to break {} naturally when I press Enter in Netbeans

I have a habit when writing code:
If I want to write a code block inside a {}, I will type {} first, then move the cursor into between { and }, press Enter and write my code.
In IntelliJ IDE, after I press Enter, IDE auto break and format for {} for me to write code (see this image with green arrow).
With Netbeans, it doesn't work like that (see the image with red screen).
My question is how to setting Netbeans IDE to work like IntelliJ to convenient for me to write code.
I have never written in NetBeans before. But I can understand you - it is so inconvenient and painful.
I have been going through all the combinations and haven't found the one needed.
The options that might repeat this behaviour somehow include:
Typing a { and pressing the enter. Code completion will automatically add the second brace and put you in the right place.
Using the combination cmd+enter and enter.
Then I figured out that we can write a macro:
split-line insert-break
The result:
Unfortunately, the macro is contextless. We can't write the condition "if the caret is between braces do our action otherwise, do the standard one". So, it can be assigned to another hotkey (not enter) to make enter work correctly in its cases.

Eclipse Autoformat Parenthesis

I have a problem whenever I use the Scanner class in my java code:
Say I type
Scanner in = new Scanner(System.in)
As soon as I press the semicolon, it becomes/autoformats to this:
Scanner in = new Scanner(System.in;
This is the only case where this issue occurs, I have never seen it happen anywhere else when coding. I also haven't found anything in the autoformat preferences that sounds like a solution to this.
I would like to know how to fix this.
I can reproduce this behaviour both in Eclipse Mars and Eclipse Neon, and for me it looks like a bug.
In particular, when I press ) to over-type the auto-inserted ), the content assist window suggesting System.in stays open, and ; then selects it and eats the ).
Therefore I opened a bug report for it:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=506729
To work around it (until it is fixed), you can disable one of the involved features: auto-inserting closing parenthesis, content assist (i. e. auto completion) or that content assist triggers on typing a semicolon. (All of these are available in the global preferences unter Java -> Editor). Alternatively you can live with the bug and close content assist either by accepting System.in with Enter, or by pressing Esc any time after the suggestion window opens but before typing the semicolon.

Eclipse isn't overwriting parenthesis

This isn't really a coding problem, but more of just an Eclipse problem.
Say you're typing x = (1), Eclipse will make the closing parenthesis for you the moment you type '('
It also normally writes over the closing parenthesis as you are typing as well.
However, for some reason when I'm typing, it doesn't automatically write over it and I'm confused because I'm pretty sure I didn't hit any special setting so I have no idea what to do to revert this.
So normally you'll type x = (1), and it'll show as x = (1), but right now it's showing x(1)). How do I change it back??
Thanks for the help!
Check in the Settings Content Assist for your Editor. It has a setting to overwrite or not. And in my case it specifically mentions you can toggle that with Ctrl Key while the assist is active. The other setting related is Editor -> Typing. It also has some brace-close settings.
1 way to solve this problem is by turning off Automatically Closed parentheses. Open the preferences for editing, then go to Java -> Editor -> Typing and turn off parentheses.

Eclipse direct shortcut instead of yellow popup?

How do I remove this middle step of having to press enter after F12 to make the actual navigation? I don't need this yellow popup telling me there's one shortcut for me.
In the second image you can see the problem: I want F12 to immediate open up the definition / declaration of the symbol my cursor is currently at. Need it for Java.
Have you tried to hover over the type/method with your mouse then hold ctrl and left mouse click.
It's a default shortcut in eclipse.
edit: sorry this should have been a comment to your question, not an answer.
The problem was indeed multiple bindings for the same key.

Categories