Editor handling of mouse double-click
I was going to file a bug on the way that the Intellij editor handles double-click, but I thought I'd first look at the documentation and see if my assumptions about what the editor should do and what the editor is documented to do line up. But I wasn't able to find information on what the editor does on double (or triple) click in the Intellij documentation.
The behavior I'm wondering about is double-click on delimiters such as {} or () (or even "" and ''). In eclipse the editor selects the text (expression/statements/data/etc) inside the delimiter, which I think is pretty handy. In Intellij double-clicking on { or } sometimes selects the contents and sometimes selects something else, or nothing at all.
Anyone know what the editor is supposed to do, and if so if it's doing it correctly?
As a side node, I noticed that the editor preferences let you remap mouse events, but it doesn't look like there's a way to search by them. That is, with keystrokes you can use a filter to search for bound keys, but I didn't see a way to create a filter to search for bound mouse events.
请先登录再写评论。
You'll find overall that IDEA is more keyboard centric than mouse centric. Everything you describe can be done via keyboard shortcuts. In particular the CTRL+W shortcut. Most of the things you describe can also be accomplished via mouse clicks. For more information on CTRL+W (which is very powerful and useful), see
Help > Help Topics > Getting Started With IntelliJ IDEA > Familiarize Yourself with IntelliJ IDEA Editor > Basic Editing Procedures > Selecting Text in the Editor
Here are some general points:
Thanks for the information, I'll have to give control-w (which is command-w on my Mac) a try.
I'm still seeing some odd behavior, and am missing some features.
Odd behavior:
- double-click on (or hit command-W just after) the } at the end of a enum or class selects just the close brace. if you hit command-W again, the line is selected. I would expect the selection to be extended to the open brace for the class/enum.
- double-clicking/command-W on the start brace of an enum/class just selects the start brace. if you hit command-W again, the entire enum/class is selected (back to the class XXX/enum XXX line). Again I would expect the brace contents to be selected in this case. In this case, clicking on/before/after the braces doesn't seem to affect the results.
- double-click on the close brace at the end of switch() selects up to the first line of the last case: (or default:) statement. I would expect the entire contents of the brace expression to be selected. Clicking on/before/afer the braces doesn't seem to make a difference.
- double-click on the start brace of a switch() selects the line that contains the switch statement itself
The fact that double-clicking on ()s has no effect seems like a bug to me, I'll file a feature request.
I just re-read your response, and maybe part of my confusion is that I have a different definition of "block of that brace" than you do. In my case I'd like to have the contents of the {} text selected in the editor. But maybe intellij defines the block as starting before the word "if" or "switch"?
It's one of the most used features for me. (I use it heavily along with the introduce variable (CTRL+ALT+V), and introduce method (CTRL+ALT+M) refactorings.) Once you get use to using it, you'll wonder how you survived without it :). And it's much easier than having to reach for the mouse all the time.
Yeah, I'm not sure why it works a little differently for a class/enum/inteface brace than for code block or method braces. It's likely simply a case that a different set of rules apply. By the way, a third typing of CTRL+W / CMD+W would select the class or enum declaration.
I'd also expect CTRL+W / CMD+W to first selct the the braces and its content, and then the include the class/enum/interface declaration. This might be a bug. But for me at least, needing to select a class block is a very rare use case. So I guess I simply never noticed it.
possible bugs? But again, I almost never double click. So never noticed. And a second typing of CTRL+W is no big deal.
Correct. It identifies the opening and closing brace and its content as a block. Not the statement prior to it as a block. An additional typing of CTRL+W/CMD+W will select that statement as well. This is simply because sometime you only want the contents of the block, and not the statement.
Is there any way for me to change in the settings if i wish to select the entire text between two braces "I want to select all these" with a double click?
Terran5992 May you elaborate? All the text between 2 braces will be selected on double click. See the gif:
Hi Konstantin Annikov
Ideally i would like to be able to double click a text within two braces and to be able to select the text without the braces.
For example, if i store a variable as a string value, i would like to be able to double click on the contents within it to select it and to change it.
In the gif
You can see that when i double click on the text within the " " braces, only the word up till "-" character is selected.
And also if i select the entire selection with braces, it includes the braces as well
in order to get the desired text ( minus the braces ) .
I would have to click and drag the cursor to the end of the text.
Feel free to vote for https://youtrack.jetbrains.com/issue/IDEA-108788
For the time being, you can use "Extend selection" action for that