How do you deselect the text in a rename dialog without moving the cursor, with the keyboard, in IntelliJ IDEA - 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.

Related

Intellij Idea - complete next parameter shortcut

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.

Returning to usage's location after Intellij IDEA "Create on Usage" intention action

Suppose I type a Java method call with an argument that I intend to make into a field:
knownObject.knownMethod(newField);
At this point, newField is highlighted as compilation error. I can press Alt+Enter and select "Create Filed 'newField'" from the menu.
That brings me up to the beginning of the class file where other fields are defined.
I can press Enter to confirm the new field's type.
Now I'd like to go back to my knownMethod() call and continue coding. How do I do that?
Bonus question: in the above situation, Ctrl+Shift+Backspace may help because I just edited the the knownMethod() call. What if I decide to first type in multiple arguments to the method? How do I get back to the argument I've just created a field for in that case?
For getting back to a previous caret location the Navigate > Back menu item usually works (CtrlAltLeft Arrow on Windows). Another option may be to use Edit > Find > Find Usages on the field (enable the Skip results tab with one usage checkbox setting)

IntelliJ IDEA find matching parenthesis / bracket

Is there any keyboard shortcut to navigate from one parenthesis ( to the matching one ) in IntelliJ?
Or even to "jump to the next opening/closing parenthesis (/) from wherever my cursor is"?
And, if there's no way to do it 'natively', are there any plugins that could add this functionality quickly and easily?
EDIT: the best solution I've found is added as a comment in liango's answer below, namely to put the cursor on the first or last brace and then press CTRL-W twice. Not ideal, but it does the job!
You can use Ctrl + [ and Ctrl + ] to navigate to a code block's start and end.
You can also use Ctrl + Shift + M to navigate between the start and end of a code block.
On Mac, you can use Option + Cmd +[ and Option + Cmd + ], and Ctrl + M
Source: https://www.jetbrains.com/help/idea/2016.2/navigating-to-braces.html
use CTRL-W to expand the selection within a bracket, use repeatedly if needed to select further out, then use the arrows.
CTRLSHIFTM is the Windows/Linux default shortcut for action "Move caret to matched brace". (For other environments see here and use the Shortcuts dropdown in the top right of the page.)
Or if desired, the shortcut keys can be changed as follows:
Go to Settings -> Keymap -> Editor Actions, or just type the name in the search box.
Here's the latest and greatest as of version 2020.1
To move caret between matching code block braces, press Ctrl+Shift+M.
To navigate between code blocks, press Ctrl+Shift+[ or Ctrl+Shift+].
From the documentation
Navigate with the caret
To navigate backwards, press Ctrl+Alt+← Left. To navigate forward, press
Ctrl+Alt+→→ Right.
To navigate to the last edited location, press Ctrl+Shift+Backspace.
To find the current caret location in the editor, press Ctrl+M. This
action might be helpful if you do not want to scroll through a large
file.
However, you can press the Up and Down arrow keys to achieve the same
result.
To highlight a word at the caret you are trying to locate, select Edit
| Find | Next Occurrence of the Word at Caret from the main menu.
To see on what element the caret is currently positioned, press Alt+Q.
To move caret between matching code block braces, press Ctrl+Shift+M.
To navigate between code blocks, press Ctrl+Shift+[ or Ctrl+Shift+].
To move the caret forward to the next paragraph or backward to the previous one, press Ctrl+Shift+A and search for the Move Caret Forward a Paragraph or Move Caret Backward a Paragraph action.
You can also select a text and then move the caret forward or backward to a paragraph. Press Ctrl+Shift+[ and search for the Move Caret Forward a Paragraph with Selection or Move Caret Backward a Paragraph with Selection action.
You can use Ctrl-[ and Ctrl-].

Move text cursor to previous string when I am at the left corner of current string

Is it possible in IntelliJ IDEA to move cursor to previous string when it is at the left corner of current string and I am pushing on left arrow keyboard key.
Let me explain:
1) Text cursor at the left corner of line 4
2) I am pushing on left arrow keyboard key
3) All I want to get - move text cursor to end of previous (3) line
But IDEA not moving text cursor from previous line, it just stays there.
Help me please.
This is because by default IntelliJ allows placing the caret after the end of line. When you press your ← key, it does not move as it would have to go to the infinite right side of your file, which is not very convenient (at least that's how I understand it :p).
Go to Settings > Editor and uncheck Allow placement of caret after end of line, this will solve your problem.

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?