IntelliJ autocompletion replacing the subsequent word - java

I've been using IntelliJ for a while now, but there's always been something that bothers me. Its to do with the autocomplete feature. This gif should be enough to illustrate.
In essence, when typing a word next to another one (that is with no space in between) regardless of the two words or the context, be it keywords or variables, the autocomplete will replace the next word by the one you complete with. I/m surprised that IntelliJ doesn't have a setting for that (at least not that I'm aware of) considering Eclipse does...
Thanks in advance!

This behavior depends on the key that you use to select the item from the completion list. If you press Enter, the selected item is inserted in the code before the following identifier. If you press Tab, the selected item replaces the identifier following the cursor.
If you prefer, you can change the behavior by reassigning keyboard shortcuts for "Choose Lookup Item" and "Choose Lookup Item Replace" under Settings | Keymap.

Related

Eclipse - Enclose selection instead of replacing

In Eclipse, when i select part of a text and press any key, the whole selection is replaced.
I would like to know how to make it, instead of replacing the text, add the key pressed to both ends of the selection, as it happens on visual studio code.
Example:
System.out.println(HelloWorld);
Select Hello World
System.out.println(HelloWorld);
Then press the " button. The code will turn to
System.out.println(");
Can i config the IDE so it will instead change it to
System.out.println("HelloWorld");
There is a already answered question like this one, but considering that one as 7 years and a lot of version old, and also considering that the answer on that one is kind of a work around, i would like to know if there's any new plugin or configuration that make it work better
From what I gather, you are wanting to do something like this?
Go to Java > Editor > Templates and add a new template, e. g. called quote, as follows:
"${word_selection}"${cursor}
Then, in the editor, write a text you want to quote, select it, press Ctrl+Space, type quote and hit Return. The highlighted text should be quoted now.
If you don't get template proposals when pressing Ctrl+Space, make sure you have them checked in Java > Editor > Content Assist > Advanced.
Just tried it and it works for me!
You can use this method for other things, like (${word_selection})${cursor} for parenthesis or '${word_selection}'${cursor} for single quote.

Unexpected Intellij Auto Complete Results

Hey there basically I'm seeing unexpected auto completion by intellij. I have tried multiple way to get it to work the way I expected it to and can't.
https://www.webmshare.com/play/yAPxo
The first line is what happens when you press tab to auto complete something and the following is when you click it in the menu.
I was wondering if it is possible to change the behavior so when I press it TAB it follows the behavior of the second line.
Thanks.
I came from work, I am glad it worked for you, so I wanted to add it as an answer.
Enter is the key for what you click in the menu to autoComplete. Tab replaces the remaining part, whereas enter just adds the completion into where the caret is. You should be able to change keys for those actions. To change those keys:
Open preferences in Intellij and go to Keymap
Change Choose Lookup Item with whichever key you want to use (it is tab key in your case I presume)

How to have Eclipse intellisense autocomplete member names?

When I type in a method name partially, Eclipse intellisense shows me the list of suggestions, but how do I select one of them using only the keyboard?
I tried pressing the Tab key, the Enter key and the Space bar, but all to no avail. It appears that the only way I can get to select one of the names from the list of suggestions is to use the mouse. This is very irritating.
Is there a keyboard short-cut to selecting a name from the intellisense suggestions?
Type in some part of the expression, use the arrow keys to navigate through the suggestions offered by intellisense. And then hit the Enter key to select the chosen expression, dismiss the pop-ups and have the selected expression appear in the editor in place of your partially typed expression.
Do not hit the tab key before making a selection as that moves focus away from the suggestions window.

text color coding in Netbeans

I have a pretty annoying issue with text highlighting on my EL statements.
I have scrolled through every field in the Options/Fonts&Colors/Syntax Control Panel three times, paying extra attention to the Expression Language options and I can not find the parameter that controls the white background of the whole ${initParam.productImagePath} expression statement.
Try looking under Fonts&Color -> Syntax. Then select the language and check all the color settings there.
UPDATE
I would add that sometimes the settings are inherited... it can be really hard to find which setting controls the color.
You can save the color settings exporting ("Export" button) then change every setting under "Expression Language" just to see if it changes.
Also, you can look through all colors in all languages and tabs until you find the color that matches the one you are seeing in the editor.
I'm guessing you may have done all this already, but I want to be sure I give the most complete answer I know of just in case.
Did you also check the entries in the Fonts&Colors Highlighting-Tab?
Your image shows that the white expression is not in the current selected line, so my guess is that you have enabled "highlight Search" (small Editor Toolbar). Another guess: if you are using the jVi Plugin, there's another highlight search parameter in jVi's settings dialog.

How to add semicolon after method call when inside parameter list in IntelliJ IDEA?

I'm finally making the voyage back to IntelliJ via Eclipse. Currently my Eclipse is set up so that if I currently have a statement such as this (where ^ denotes where my cursor currently sits):
foo.bar("hello"^)
and I hit the semi-colon (;) key, it will automatically put the semi-colon at the end of the statement:
foo.bar("hello");
Currently IntelliJ does this:
foo.bar("hello";)
Meaning I will have to explicitly type the closing bracket before typing the semi-colon.
Not a huge problem obviously but I have found myself putting the semi-colon in the wrong place a few times today as I make the transition back to IntelliJ and thought that it may be more efficient (for both my fingers and brain) not to have to type the closing bracket.
For Windows or Linux users, Ctrl+Shift+Enter.
For macOS/OS X users, ⌘ Command+⇧ Shift+Enter.
That finishes the statement you're currently writing. Try it in a few different situations, like in if statements, for loops etc, and you'll see that it'll complete the line and open some curly braces for you if necessary.
You can add a keymap of your own. I added Ctrl+; to my Keymaps for the "Complete Current Statement" action. This saved me an extra key stroke and made it a little bit more intuitive.
Go to Settings > Keymap
In the search box, enter "Complete Current Statement".
Right-click on the entry and select "Add Keyboard shortcut"
With the First Stroke field hightlighted, enter your key combination. E.g., Ctrl+;, which will display as Ctrl+Semicolon
Click OK, and OK to save and exit.
You can opt to remove or keep the existing mapping. Should look something like this when you're done:
if you want always have it just do this

Categories

Resources