NetBeans IDE Code completion shortcut - java

I have two problems.
First when i type code, netbeans automatically completes the brackets. Now what i need is to move cursor out of brackets to type the semicolon. I have to do it with the right arrow key, but i have seen tutorials in which coders to it faster. Is there some other short key or a way to do it quicker i.e from the keys under my hands?
Second the Netbeans suggestion are quite slow in my machine. Is there a way to make them load faster?

Also, CTRL-; adds a semicolon at the end of the current line, without moving the cursor. The shortcut can be changed: Menu Tools -> Options -> Keymap and search for "Complete line".
There is also in the keymap an option for "Complete line and create new line", which does the same but then puts the cursor at the start of a newly created line below. By default, I had no mapping to it, but I added it as CTRL-SHIFT-;.

Type the closed backet. Netbeans realizes what's going on and does exactly what you describe.

Related

How to make Spring/Eclipse IntelliSense autocomplete like in Visual Studio?

I am a .net developer and from last year I started learning Java. But something make me sad, and that is the Java autocomplete IntelliSense. After I choose something from IntelliSense, a method name for example, it put the method name with the default parameter as well. I don't want that!!! I want to work like in Visual Studio, just to put there the name and that's it because usually when I do that I already copy paste a line from above and I want to change only the class method name...
How to change how this autocomplete works?
I attached a photo after I choose a method from that object, but that line was copied from above before choosing.
Do one of the following:
Press Ctrl while selecting a code completion proposal
Configure overwrite instead of insert code completion behavior as default:
In Window > Preferences: Java > Editor > Content Assist in the first section choose Completion overwrites
Your question was already asked here. Basically the gist of it:
Eclipse already has its own sort of Intellisense that only gets triggered by a "." by default. You can change the settings under:
Window -> Preferences -> Java/Editor/Content Assist
A problem, if you want the Intellisense to be always active. The "fix" would be to always use "ctrl"+"space" to open the Intellisense GUI. (Or, even better, to add every letter and character to the Intellisense triggers under: Window -> Preferences -> Java/Editor/Content Assist)

Intellij idea how to automatically fill in bug tips, which shortcut keys?

I want to automatically fill in the missing braces with shortcuts. Does Intellij idea have such shortcuts?
Just like in the figure
There is the "complete statement" shortcut: CTRL+SHIFT+ENTER
The result depends on the current context (language, place...). It can add semicolons, braces, parehtheses...

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.

How do I rename all Scanners or object?

e.g., I have named my Scanner object readsir" throughout my code.
[Scanner readsir= new Scanner(new File("word.txt"));]
However, I am worried my professor would expect a different Scanner or object name. Every time I highlight one "readsir" in the program, all the "readsir"s are highlighted. So, if i want to change all the "readsir"s to objIn, is there any way to do that? I am new to eclipse and java programming so I am sorry if it is too obvious.
I went through the program and changed all the words manually, but one of my programs is 700 lines long, so I would like to discover a new way for long programs.
select the variable -> right click->source->refactor. Then type in the new name of the variable and press enter
Or
Select the variable and press, Alt+Shift+R
Assuming you are using eclipse you have a shortcut for that. Highlight the variable name you want to rename and press alt+shift+r, you'll see a box around the name. Rename it and press enter, the name should change everywhere that same variable is used.
If you're using another IDE you'll have a similar solution. Check with a right click or in the menu bar on top and search for a tool named refactor or refactoring.

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.

Categories