Intellij Idea - complete next parameter shortcut - intellij-idea

Example:
Author author = new Author("Jack", "Daniels");
In Exlipce when filled "Jack" and pressed "enter" - it automatically went to second parameter and let me fill second one. In Intellij I always have to click with mouse, or use arrow keys.
Is there a shortcut in Intellij to make it quicker? I can't find one myself.

Since IntelliJ 2018.2
You can now jump outside the closing bracket or quote with Tab.
(from: https://blog.jetbrains.com/idea/2018/07/intellij-idea-2018-2-macbook-touch-bar-java-11-breakpoint-intentions-spring-boot-version-control-and-more/)
Basically it means if you have:
Author author = new Author("Jack<cursor>");
And you press Tab, the cursor is placed like this:
Author author = new Author("Jack"<cursor>);
Note: it doesn't matter where the cursor is initially, as long as you are somewhere inside the quotes when you press Tab the cursor is moved outside and placed behind it. If you want to enter the next parameter you have to manually type the comma and String.
The option can be found under: Settings -> Editor -> General -> Smart Keys and is called Jump outside closing bracket/quote with Tab
There are some other useful options there as well like insert pair quote and insert pair brackets.
If you want to go more advanced you can have a look into Live Templates.

Related

Wrap an existing variable to be the argument to a newly-typed method call in IntelliJ code editor

I have this:
this.label = label;
I want this:
this.label = Objects.requireNonNull( label );
Is there a shortcut way to edit such a line rather than me typing in the Objects.requireNonNull() followed by cut/paste or dragging the variable to inside the parentheses?
I can imagine selecting the variable (label in this example), then pressing some keystroke that lets me type the method call, and upon hitting Return puts that var within the parens.
Surround live template
You can create a surround live template.
Surround templates wrap a block of the selected code with the text specified by the user. For example, T expands into a pair of tags, for which you can specify a name. You can also select a block of code, then press Ctrl+Alt+J to open the Select Template popup and select the T template to wrap the selection with a pair of tags.
Here is an example of creating your desired Objects.requireNonNull, here with abbreviated name ornn.
To invoke your live template:
Select the text you want to surround.
Press the keystroke currently designated for live templates.
You discover that needed keystroke by looking at Preferences/Settings > Keymap > Other > Surround with Live Template….
That shortcut would be…
macOS: Option + Command + J
Windows: Control + Alt + J
Structural Search
Another option would be to configure Structural Search and Replace inspection with the quick fix, then apply it via the Alt+Enter on the matched code.

How to change key to 'accept' intellisense 'offer' for VB.Net in Visual Studio 2015 (update 3)

When I'm coding in VB.Net in VS2015 I would like to use CTRL+SPACE to select Intellisense proposal when coding. Currently I have to use SHIFT+SPACE and I see no way to change it.
In the preceeding example screenshot it is visible that I have 3 potential options to autocomplete. I can select any of them with key up/down but in order to select the proposal I have following options:
Press 'SHIFT+SPACE' - this will accept the proposal and position the
carret right after the word enabling me to press '(' or whatever else
I want
Press 'SPACE' - this will accept the proposal but it will also
add a white space at the end which is ok for properties/fields but
not good for methods
Press '(' - this will accept the proposal but it
will also add a '(' character at thend which is ok for functions/sub
but not good for properies/fields
Press 'CTRL+SPACE' - this actually does not do anything :(, CTRL on its own makes the Intellisense menu gray-out
In the key configuration window I found the Edit.CompleteWord command:
However this command already has CTRL+SPACE assigned it but it simply does not work. In addition SHIFT+SPACE is not mentioned as one of the keybindings.
Note:
VS2015 does have a flag 'Toggle Completion Mode' but I actually see no difference if this option is checked or not.
you can Use Tab and this will accept the proposal and position the current right after Tab Use space it well show You next Complete Word .

intellijidea code completion not new variables

I'm using Android Studio and I have code completion enabled as in picture.
I have enabled "Autopopup code completion" and "Insert selected variant by typing dot, space, etc..".
I want to write:
Drawable d = new BitmapDrawable(....);
I write "Dr", appears the popup, I click the space bar, and it writes "Drawable". It's all ok.
Then I write "d", appears the popup with "drawable" suggested, I click the space bar, and it writes "drawable".
But I want to write "d".
Is it possible to change this option applying only to classes and methods and not to new variables?
There is not a way to have code complete only apply to classes and methods and not to new variables. You have three options:
Turn off the Insert selected variant by typing dot, space, etc." options. You will then need to use Enter (to insert) or Tab (To overwrite) when you want to select an item from auto complete. The . (period/dot) key will still work when completing classes if you want to invoke a static member. (This is likely the best of the three choices and is the default behavior.)
After you type d for the variable name, hit Esc to close the auto complete popup before you hit the Space.
Turn off "Autopopup code completion" so that you have to manually activate it each time via Ctrl+Space

Rename wxTreeCtrl item

I want the normal rename on double click and/or F2
So:
new wxTreeCtrl(this,IDC_Tree,wxPoint(-1,-1),wxSize(-1,-1),
wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT | wxTR_EDIT_LABELS);
Double click does not rename. ( it displays the children of a parent node )
F2 does not rename
What does work is
click node to select it
press F2 key
click node again - now I am able to type in a new name
It does the job, I suppose, but I don't want to have to explain this to every user.
wxWidgets v2.9, C++, windows
F2 doesn't work out of the box for wxTreeCtrl (it does work for wxDataViewCtrl though), you'll need to handle it and call EditLabel() yourself.
Double click is never used for renaming the items, only for activating them. What works for renaming is "slow click", i.e. a click on an already selected item which comes late enough to not count as a second click of a double click. This is how it works in the standard Windows treeview control and in wxTreeCtrl too.
Could you not just catch an event of type wxEVT_COMMAND_TREE_ITEM_ACTIVATED and then use wxTreeCtrl::EditLabel to start the editor?

How do you deselect the text in a rename dialog without moving the cursor, with the keyboard, in IntelliJ IDEA

I'm using IntelliJ IDEA 10.5.2
Example:
Say I want to rename this class to SomeAwesomeClass.
If we do the Rename refactoring we get a dialog like this:
It has the cursor in the right place however the text is selected. So if we started writing "Awesome" the original name would disappear. So what I want to do is keep the cursor position but deselect the text.
I have not been able to find any way to do this. All things I've tried ether moves the cursor or removes the text or does nothing.
Left or Right keys goes to the left or right.
Up or down does nothing.
Esc closes the dialog.
PageUp or PageDown does nothing.
Home or End goes to left or right.
The fact that the cursor is in the right place to start with makes me believe this is a existing feature...
In 11-eap (110.365) when you rename a class (Shift+F6):
at first full class name is selected and you have a dropdown with suggested names, press Esc
full class name is still selected (dropdown gone), press Esc again
you have class name unselected, and can write at cursor
Note a third Esc will exit rename.
In earlier versions (10.5.2) you can do a trick:
Before rename select one character (shift+arrow forward) where you want to end up (in SomeClass select C) then Shift+F6 and arrow back. I know it is a lot of keys to presses but in a long class name this helps.