keybinding?

Hello all,

Netbeans has a keybinding which I'm missing in IDEA. The nb
keys are ^K and ^L. What they do is to find a word going back or forward in the text that matches the word one is currently typing.

So, the code

int anDouble = 0.;
int anInt = 0;
System.out.println(an|

and hitting ^K at the | would fill in the word anInt. Hitting ^K a second time would complete with anDouble
and so on. ^L does the same but going forward in the text.

I have to believe the IDEA has this same action, but I haven't found it. Can anyone please provide a pointer?

Thanks!

20 comments

Alan Stange wrote:

Hello all,

Netbeans has a keybinding which I'm missing in IDEA. The nb
keys are ^K and ^L. What they do is to find a word going back or forward in the text that matches the word one is currently typing.

So, the code

int anDouble = 0.;
int anInt = 0;
System.out.println(an|

and hitting ^K at the | would fill in the word anInt. Hitting ^K a second time would complete with anDouble
and so on. ^L does the same but going forward in the text.

I have to believe the IDEA has this same action, but I haven't found it. Can anyone please provide a pointer?

Thanks!


It sounds to me like you're trying to do something in a way that IDEA
supports in some other way. Why do you so frequently want to jump around
in that way?

Anyway, I have mapped "Search->Incremental Search" to Ctrl+F which
allows something similar to what you're requesting.

Also, this feature would make for an easy plugin.

0

Hi,

I wrote this code and pressed Ctrl+Space. I got a list containing
anDouble and anInt (in that order) and anInt was selected by default.

Is that really that different than what you are asking?

Amnon


Alan Stange wrote:

Hello all,

Netbeans has a keybinding which I'm missing in IDEA. The nb
keys are ^K and ^L. What they do is to find a word going back or forward in the text that matches the word one is currently typing.

So, the code

int anDouble = 0.;
int anInt = 0;
System.out.println(an|

and hitting ^K at the | would fill in the word anInt. Hitting ^K a second time would complete with anDouble
and so on. ^L does the same but going forward in the text.

I have to believe the IDEA has this same action, but I haven't found it. Can anyone please provide a pointer?

Thanks!

0

Amnon, he's asking for something completely different. I think he's asking for a
key to navigate between usages and declarations of a symbol.

Amnon I. Govrin wrote:

Hi,

I wrote this code and pressed Ctrl+Space. I got a list containing
anDouble and anInt (in that order) and anInt was selected by default.

Is that really that different than what you are asking?

Amnon


Alan Stange wrote:

>> Hello all,
>>
>> Netbeans has a keybinding which I'm missing in IDEA. The nb
>> keys are ^K and ^L. What they do is to find a word going back or
>> forward in the text that matches the word one is currently typing.
>>
>> So, the code
>>
>> int anDouble = 0.;
>> int anInt = 0;
>> System.out.println(an|
>>
>> and hitting ^K at the | would fill in the word anInt. Hitting ^K a
>> second time would complete with anDouble
>> and so on. ^L does the same but going forward in the text.
>>
>> I have to believe the IDEA has this same action, but I haven't found
>> it. Can anyone please provide a pointer?
>>
>> Thanks!

0

Uhhh, what in the world are you talking about?

I'm not doing any jumping around. And I'm asking if in fact IDEA does support this in any way.

Searching has nothing to do with this...

0

I think what Amnon said is the closest IDEA comes to what you're looking
for. Also, if you hit Ctrl + Shift + Space it will suggest variables after
the line you're in too. Not sure why Ctrl+Space doesn't work in that case.

"Alan Stange" <no_mail@jetbrains.com> wrote in message
news:30128771.1130202900989.JavaMail.itn@is.intellij.net...

Uhhh, what in the world are you talking about?

>

I'm not doing any jumping around. And I'm asking if in fact IDEA does
support this in any way.

>

Searching has nothing to do with this...



0

Yes, ^Space is very different.

Yes, ^Space does give a menu, but then I need to find an arrow key, scroll down, hit return, and now get back to editing.

The netbeans keybinding is very elegant and I miss it very much. One keystroke inserts the last text which matches, second keystroke matches from two words back, etc.

So, code like

String aa = "a";
String ab = "b";
String c = a|

would add "b" on first keystroke and "b" on the second keystroke.

By comparison, ^Space gives every possible completion but I have to navigate a menu with a bunch of other keys.

Even worse is ^Shift-Space, which adds a ";" at the end of the completion! What if I want to call a method on the completion? So now I need to remove the ;


Yes, the distinction is subtle. Netbeans has the same ^Space completions as does IDEA, but I find I use the word matching far more often. Of course, it matches quoted text, as well.



Here's a snippet from the netbeans docs:

  • Word Matching


Word matching is a dynamic approach to entering frequently used words. After you type the first part (the prefix) of a desired word, the Editor can generate the rest of the word based on a list of all words in the document with the same prefix. You can search through the matching words in reverse or forward direction. If your first match does not generate the desired word, you can press Ctrl-K or Ctrl-L multiple times to find additional matches.

0

Like I said, IDEA doesn't have anything like that but it sounds pretty cool.
Maybe you should file a request or write a plugin.

"Alan Stange" <no_mail@jetbrains.com> wrote in message
news:16573168.1130204739553.JavaMail.itn@is.intellij.net...

Yes, ^Space is very different.

>

Yes, ^Space does give a menu, but then I need to find an arrow key, scroll
down, hit return, and now get back to editing.

>

The netbeans keybinding is very elegant and I miss it very much. One
keystroke inserts the last text which matches, second keystroke matches
from two words back, etc.

>

So, code like

>

String aa = "a";
String ab = "b";
String c = a|

>

would add "b" on first keystroke and "b" on the second keystroke.

>

By comparison, ^Space gives every possible completion but I have to
navigate a menu with a bunch of other keys.

>

Even worse is ^Shift-Space, which adds a ";" at the end of the completion!
What if I want to call a method on the completion? So now I need to
remove the ;

>
>

Yes, the distinction is subtle. Netbeans has the same ^Space completions
as does IDEA, but I find I use the word matching far more often. Of
course, it matches quoted text, as well.

>
>
>

Here's a snippet from the netbeans docs:

>

  • * Word Matching

>

Word matching is a dynamic approach to entering frequently used
words. After you type the first part (the prefix) of a desired word, the
Editor can generate the rest of the word based on a list of all words in
the document with the same prefix. You can search through the matching
words in reverse or forward direction. If your first
match does not generate the desired word, you can press Ctrl-K or Ctrl-L
multiple times to find additional matches.

>



0

Alan Stange wrote:

Uhhh, what in the world are you talking about?


I don't know how to answer that question.

I'm not doing any jumping around. And I'm asking if in fact IDEA does
support this in any way.


You want your cursor to jump to different parts of the editor based on what word
is at the cursor, right? IDEA doesn't support this feature exactly.

Searching has nothing to do with this...


I think it's almost the same thing as incremental search.

0

So, code like

String aa = "a";
String ab = "b";
String c = a|

would add "b" on first keystroke and "b" on the second keystroke.


Do I understand you correctly: if you have following code

String aa = "a";
String ab = "b";
String c = ab|

and press Ctrl-K, the 'b' should be deleted and add an 'a' instead:

String aa = "a";
String ab = "b";
String c = aa|

Is this how it should work?

Tom

0

CtrlAltShift+Space - complete word.
If you won't get popup how you will choose word that located many screens from current position? Hit Ctrl+K 10 times?

0

Please be patient "Uhhh, what in the world are you talking about?" not best way to find answers here.

0

Hi,

  • Keith Lea wrote:


>> I'm not doing any jumping around. And I'm asking if in fact IDEA
>> does support this in any way.

You want your cursor to jump to different parts of the editor based
on what word is at the cursor, right?


No, I guess he wants "unintelligent" code-completion, based purely on
previous/following text.

-hs

0

Hi,

  • Dmitry Kashin wrote:

CtrlAltShift+Space - complete word.


That could be from Emacs. ;)

-hs

0

No, this doesn't work right either

new Array|

gives me a popup with ArrayIndexOutOfBoundsException, which isn't anywhere in my current text.

Yes, if I have 10 different words in my current document
with the word Array as a prefix and I want the one 10 unique matches back, then I would either type one extra letter to make the match more unique, or hit ^K 10 times. It's still faster then getting a popup menu and having to find arrow keys, etc.

The editor already has the word I want in it, why do I need a menu with completing words from other contexts?

0

Yes, emacs does have this feature as well. But this binding isn't the right one.

0


I'm not doing any jumping around. I don't want the cursor to move anywhere, except to insert the text of possible completing words.

The word matching isn't incremental as one types, it's take
the token as partially entered, find other tokens/text which matches and insert it right where the cursor currently is.

0

No. No text is deleted.

Text would be added in this case if some token that starts with aa already exists in the current text.

If no such token exists, then no additions are made.

This is basically the same as ^Space, but without the popup menu, the arrow keys, return key, and the possible completions are all from the current document.

It's very simple, powerful and fast.

0

Hi,

  • Alan Stange wrote:

Yes, emacs does have this feature as well. But this binding isn't
the right one.


I meant the ammount of keys. :)

JFTR: Completion in Emacs is Alt-/.

-hs

0

Alan Stange wrote:

I'm not doing any jumping around. I don't want the cursor to move anywhere, except to insert the text of possible completing words.

The word matching isn't incremental as one types, it's take
the token as partially entered, find other tokens/text which matches and insert it right where the cursor currently is.


I see now. I think what you want is "hippy completion" as it is called in
Eclipse and emacs. You should file a request at http://jetbrains.net/jira

0

I can see that having both completion methods would be useful. The existing IDEA code completion is useful for pulling in class names and library constants, etc., but a rapid incremental match from local code would make entering local variables, fields, and methods faster.

Put in a JIRA request, it doesn't sound that difficult to do.

0

Please sign in to leave a comment.